Question

I am using Three20 for the iphone and I am trying to change what a method does within it by using a class category. It compiles fine, but I never reach the break point in it.

I'm assuming a class category affects all instances of the class, so I don't have to recompile the static library for it to work.

I also know that the class I'm using for the category is being seen because if I add a 'x' to the end of the class name when I interface and implement the category the compiler fails.

Any guidance here is VERY appreciated.

Was it helpful?

Solution

As is pointed out here, you'll need the -all_load option to be set in your application's Other Linker Flags in order to have categories be linked against static libraries in iPhone OS 3.0. -ObjC should do the trick as well, but it's not working on the current SDK. As of the LLVM compiler in Xcode 4.2, they fixed the linker bug that prevented the Other Linker Flag of -ObjC from working correctly, so you no longer need to use -all_load (which has some nasty side effects). -ObjC should be all you need to get categories to be pulled in from your static library.

This might be contributing to your problem, although I think Three20 requires those linker flags to be set for it to link properly with your application in the first place, so you might already have these flags in place.

OTHER TIPS

When two categories override the same method on the same class in the same binary, it isn't defined which override will take precedence. For best results, create a subclass and then override the method on that. Alternatively, since Three20 is Apache-licensed, you can make your change in the library itself.

I have a project that is linking to a static library and yes the -all_load flag is required when installing on the device with the 3.0 sdk. -ObjC was all that was needed for the simulator.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top