A method from the category throws an exception after upgrading to Xcode 4.2 / iOS 5

I have a category that extends NSMutableArray with a shuffle method. The category is declared and implemented in the .h file, which is included in the .pch file. Worked fine on iOS 3.xx and 4.xx. Yesterday I installed Xcode 4.2. A recompiled application with the base SDK installed in 5.0 and the deployment target for 3.2 throws -[__NSArrayM shuffle]: unrecognized selector sent to instance ...

I tried the simulator iPhone 5.0, the simulator iPad 5.0, iPhone 4G with iOS 5 - no difference.

Now, if I moved the declaration / implementation to .m , where the class sending the shuffle message is implemented, the application works fine. The original .h indeed imported - if I just copy the code from the original .h to .m , the compiler complains about a duplicate declaration.

+4
source share
1 answer

Upgrading to Xcode 4.2 caused the compiler to change from GCC to Apple LLVM. And LLVM do not like the implementation in .pch. Extracting the implementation into a .m file, importing the original .h directly, compiling with GCC all solves the problem.

+1
source

All Articles