Comments Off

Objective-C: Categories and static libraries

Posted December 28th, 2009 in Cocoa by Chris Gummer

After taking advantage of Objective-C categories to add some additional behaviour to NSArray and NSDictionary, I decided to extract the new classes I created into a static library. However, when running my application that made use of this static library, I received the following error:

unrecognized selector sent to instance

There is an Apple tech note that explains how to resolve this – QA1490

To resolve this issue, the static library should pass the -ObjC option to the linker. This flag causes the linker to load every object file in the library that defines an Objective-C class or category. While this option will typically result in a larger executable (due to additional object code loaded into the application), it will allow the successful creation of effective Objective-C static libraries that contain categories on existing classes.

Comments Off

Adding iPhone 3.x features and retaining 2.x compatibility

Posted December 8th, 2009 in Cocoa by Chris Gummer

I’ve been planning on writing a post on how to add new features that utilise iPhone OS 3.x, to your iPhone 2.x OS app whilst maintaining backwards compatibility. However, I recently came across some Apple sample code that demonstrates how to do this – Apple’s MailComposer Sample Code