cocoa

How to advertise a service using Bonjour across subnets?

I am familiar with the usage of Bonjour for advertising services on the "local" domain. I have worked through several examples, and I know the corresponding Cocoa classes I use for that. I am curious about how I advertise a simple Bonjour service to a different subnet. Specifically, I am trying to write a network service that runs on ...

OSX Quicklook debugging

I am writing a quicklook plugin for an MPO file. The plugin isn't that much of a problem, but the problem is trying to debug it. Apples documentation says that to debug you use qlmanage -r <filename> And I have. However, none of my breakpoints are matched. I assume this is as it hasn't matched my quicklook plugin with the type. Usin...

Different between self.myIvar and myIvar?

What's the difference between referring to an instance variable in an objective-c class as this: self.myIvar and myIvar if it's been declared as a property in the header and synthesized? ...

Playing one mp3 file (in loop) in OS X 10.5 or higher

How to play an mp3 file, on repeat, on OS X 10.5 or higher? Please reply with a code snippet. Thanks. ...

Sharing Constants Between Cocoa and Cocoa-Touch apps

I have a class that I want to share between two different applications. The on,y real difference is the base framework it references. Cocoa imports and of course Cocoa-Touch imports . I would like to use a precompiler directive to check what I am compiling to and allow the correct import. What can I check to see if what My target is...

How to know all messages that one object can response?

Hi guys, can I get the list of messages that one object can response in runtime? (in Cocoa). ...

About getting a new NSManagedObject object.

I watch the Core Data guides, and there are two way to obtain a new NSManagedObject instances. - initWithEntity:insertIntoManagedObjectContext: of NSManagedObject class + insertnewObjectForEntityForName:inManagedObjectContext: of NSEntityDescription class Are there any difference between both methods? Or, they just mean the same thin...

NSTextView - using initWithHTML with tables

Hi, I'm trying to format some text in NSTextView to be placed in a single line with black background. One piece of text needs to be left aligned, the other piece (but still in the same line) needs to be centered. NSString *header = [NSString stringWithFormat: @"" "<table style=\"width: 100%; background: black; " ...

Equivalent of .Net Data Repeater in Cocoa

Hi, I'm a total noob to Xcode and Interface builder. I'm on version 3.2.3 and OSX 10.6.4. What I'd like to know, and haven't been able to find out, is how to display a list of n items. Using .Net, I'd probably use a Data Repeater control and then use that to repeatedly populate the controls I'd like to display. Is there an equivalent ...

How to parse a date from a string containing a time zone

I need to parse following string into NSDate. Example: 2008-09-28T02:48:16+05:30 I tried following but it is not working NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; [dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZ"]; NSLog(@"Date=%@",[dateFormatter dateFromString:@"2008-09-28T02:48:16+05:30"]);...

CFMessagePort name conflict

I have created a worker thread that uses a CFRunLoop to receive messages from a CFSocket. Now I need to send other messages to the worker thread so a CFMessagePort looked ideal. However its entirely non obvious to use: The documentation states that the name parameter is needed when communicating between processes. In my worker thread I...

System-wide hotkey for an application

I have a simple window with 3 buttons and I am trying to add a system-wide hot key so i can "press" those buttons without having to switch to that app, press a button and then go back to what I was doing. Something like Cmd+Shift+1 press button 1, Cmd+Shift+2 press button 2, etc. Is there any way to achieve this in Cocoa (with Objectiv...

For loops in Objective-C

counter = [myArray count]; for (i = 0 ; i < count ; i++) { [[anotherArray objectAtIndex:i] setTitle:[myArray objectAtIndex:i]]; } I would like to do it the objective C 2.0 way but can't seem to find how to access the index 'i' (if that's possible anyway). for (NSString *myString in myArray) { [[anotherArray objectAtIndex:i]...

Reading an async socket continuously

I have already read other similar question about that problem, but that don't work for me. I'm building an iPhone app that talks with a TCP server (windows, but never mind) and I'm using AsyncSocket from cocoaasyncsocket (googlecode). It's a very useful class, but I can't use that at all. In my code I create a "connector" which I all...

Impossible issue connecting to Windows Live Messenger network

This issue is giving me serious headaches, I don't have a clue what's going on here. If you don't have any experience with the Windows Live network, I ask you to read this anyway, maybe it has nothing to do with it and am I overlooking something totally unrelated. In short: I wrote an Objective-C class that allows me to connect to the W...

How can I get the contents of an std::string into a CFData object?

I've got a function that returns a std::string object. I'm working with Cocoa/CoreGraphics and I need a way to get the data from that string into a CFData object so that I can feed that into a CGDataProviderCreateWithCFData object to make a CGImage. The CreateCFData function wants a const UInt8* object (UInt8 being a typedef for unsign...

iPhone - Store float in SQLite thru CoreData

Hi everyone, I store a float number in my SQLite (through core data) like this: unit.conversion = [NSNumber numberWithFloat:0.001]; When I look at the SQLite database the value is 0.0010000000474974513 unit.conversion is an optional float in my datamodel... What's wrong with that? Thanks ...

CALayer flickering when adding a foreground layer to IKImageBrowserView items with garbage collection on

I'm trying to implement a technique similar to the one in the ImageBrowserViewAppearance sample code from Apple (located here: http://developer.apple.com/library/mac/#samplecode/ImageBrowserViewAppearance/Introduction/Intro.html ), where CALayers are generated on top of the items in the IKImageBrowserView to customize the appearances of ...

Where does a cocoa app main() function go?

I'm trying to build a super-simple Cocoa app, basically one that has one function (for example, main()) with a while loop. It does some stuff, does a curl request, then waits a few seconds before starting over. I've got my project all setup in XCode with all the necessary variables and functions, but I don't know where to put my main() ...

Interface Builder Plugin Custom NSView Dragging

I have created a simple custom NSView (plugin item) When i do resize my NSView in interface builder - everything displays normally (black rect) But when i drag NSView to reposition it, nothing is displayed. What method should be implemented to fix this issue? -(void)drawRect:(NSRect)dirtyRect { [super drawRect:dirtyRect]; [NS...