cocoa

Why can I select aliases but not symbolic links in NSOpenPanel?

I want to create an NSOpenPanel that can select any kind of file, so I do this NSOpenPanel* panel = [NSOpenPanel openPanel]; if([panel runModalForTypes:nil] == NSOKButton) { // process files here } which lets me select all files except symbolic links. They're simply not selectable and the obvious setResolvesAliases does nothin...

Why shouldn't I use Objective C 2.0 accessors in init/dealloc?

In @mmalc's response to this question he states that "In general you should not use accessor methods in dealloc (or init)." Why does mmalc say this? The only really reasons I can think of are performance and avoiding unknown side-effects of @dynamic setters. Discussion? ...

What's the best way to validate a user-entered URL in a Cocoa application?

I am trying to build a homebrew web brower to get more proficient at Cocoa. I need a good way to validate whether the user has entered a valid URL. I have tried some regular expressions but NSString has some interesting quirks and doesn't like some of the back-quoting that most regular expressions I've seen use. ...

What is the cost of using autorelease in Cocoa?

Most of Apples documentation seems to avoid using autoreleased objects especially when creating gui views, but I want to know what the cost of using autoreleased objects is? UIScrollView *timeline = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 20, 320, 34)]; [self addSubview:timeline]; [timeline release]; Ultimately should I use ...

How can I get notified when the user finishes editing a cell in an NSTableView?

I need to know when the user finishes editing a cell in an NSTableView. The table contains all of the user's calendars (obtained from the CalCalendarStore), so in order for the user's changes to be saved I need to inform the CalCalendarStore of the changes. However, I can't find anything that gets called after the user finishes their edi...

Is there a way to suppress warnings in Xcode?

Is there a way to suppress warnings in Xcode? For example I am calling an undocumented method and since the method is not in the header I get a warning on compile. I know I can add it to my header to stop the warning, but I am wondering if there is a way other then adding it to the header (so I can keep the headers clean and standard) t...

Is there a pattern for dealing with non-memory resources on cleaning up an ObjC object?

It's usual for objects which have some state related to a non-memory resource to provide a method for explicitly 'finishing' with that resource. Is there a preferred common practice for dealing with the case where an object deallocation is attempted while still in the "using my resource" state? I have seen a couple of different approache...

Locating bundles by identifier

I want to create a bundle from an arbitrary bundle identifier e.g. com.apple.iokit.IOStorageFamily It's not an unreasonable thing to do as bundle IDs are supposed to be unique, however the obvious code does not work: NSString* bID = @"com.apple.iokit.IOStorageFamily"; NSBundle* bundle = [NSBundle bundleWithIdentifier:bID]; This cod...

How to determine if currency symbol is to the left or right of a number on MacOS

How do I determine if the currency symbol is supposed to be on the left or right of a number using CFLocale / CFNumberFormatter in a Mac Carbon project? I need to interface with a spreadsheet application which requires me to pass a number, currency symbol, currency symbol location and padding instead of a CStringRef created with CFNumbe...

Core Animation rotating a layer around arbitrary point

How can I rotate a layer using Core Animation around an arbitrary point? ( In my case a point that is not inside the layer I want to rotate ) I prefer doing this without changing the anchor point, because unless I get something wrong every time I change the anchor point it also changes the position of the layer. I tried something like ...

Cocoa Distributed Objects, GC client, non-GC server

I have a setup where there are two Cocoa processes, communicating with Distributed Objects (DO). The client is using garbage collection, the server is not. It seems that the client hangs on to the distant objects outside of my direct references to them. This means that even after I don't have references to the objects, they hang around ...

Setting QTMovie attributes

I'm trying to create a QTVR movie via QTKit, and I've got all the frames in the movie. However, setting the attributes necessary doesn't seem to be having any effect. For example: NSNumber *val = [NSNumber numberWithBool:YES]; [fMovie setAttribute:val forKey:QTMovieIsInteractiveAttribute]; val = [NSNumber numberWithBool:NO]; [fMovie ...

Is it possible to design NSCell subclasses in Interface Builder?

I'm trying to subclass NSCell for use in a NSTableView. The cell I want to create is fairly complicated so it would be very useful if I could design it in Interface Builder and then load the NSCell from a nib. Is this possible? How do I do it? ...

Multiple NSURLConnection delegates in Objective-C

I have two NSURLConnections. The second one depends on the content of the first, so handling the data received from the connection will be different for the two connections. I'm just picking up Objective-C and I would like to know what the proper way to implement the delegates is. Right now I'm using: NSURL *url=[NSURL URLWithString...

Implementing a KVO/Bindings-Compliant Bridge-Pattern in Cocoa

Hi folks, I'm trying to implement a simple object bridge in cocoa where the bridge object acts as a kvo/bindings-compliant drop in for some arbitrary other NSObject instance. Here is my problem (more details in the code below): A bridge object acts as a drop in for a Person-Object, with an NSString* property called name and an Address...

Cocoa Bad Habits

What are those bad habits you've developed since you've started coding in Cocoa? I think making a list of bad habits and actively adding to it and, more importantly, breaking those habits is a good technique to produce your code quality. So start now, get your bad habits off your chest. Maybe other people share your bad habits. ...

How do I profile how long a piece of code takes to execute in Objective-C/Cocoa for optimization purposes

Lets say I've got two interchangeable pieces of code and I want to figure out which one of them takes less processor time to execute. How would I do this? To get a very rough estimation I could just put NSLog() calls on either side of the code I wanted to profile, but it seems like the processor being otherwise very busy could skew the ...

Find out location of an executable file in Cocoa

The simple question is: how to find out the location of an executable file in a Cocoa application. Remember that, in many Unix-like OS people use PATH environment to assign the preferred location for their executables, especially when they have several versions of same application in their system. As a good practice, our Cocoa applicat...

How do you start debugging a Cocoa app with a URL?

I'm debugging a Cocoa application that can act as a handler to a custom URL protocol. The application works fine when I click on a link after the application has launched, but something is causing the app to crash if it has not launched at the time the link is clicked. Is there any way that I can start the app in the debugger and "fool"...

Automatically generated predicate row templates for to-many key?

In my Core Data managed object model, I have an entity Foo with a to-many relationship (with a to-many inverse) to entity Baz named baz. Baz has a string property named "tag". When I use [NSPredicateRowEditorTemplate templatesWithAttributeKeyPaths:[NSArray arrayWithObject:@"baz.tag"] inEntityDescription:FooDescription] to create the row ...