Short answer:
Your problem is ARC, you should be able to fix it by adding -fno-objc-arc
to just this file in your project config (Build Phases > Compile Sources > Compiler Flags) Also make sure you set error
to nil
in load
before you swizzle - that happens automatically under ARC.
Explanation:
ARC needs to know the return type of a method call, and the ownership of the returned value, so that it can manage the reference appropriately. This causes a problem with performSelector:withObject
as selectors in Objective-C are untyped and so ARC cannot know the return type. The method is declared to return id
, but with an appropriate selector may in fact return void
- ARC will attempt to retain the return value, and doing that when nothing has in fact been returned doesn't work too well as the return value in that case is essentially garbage.
Turning off ARC for just this one file has no significant impact, your xxxx_performSelector:withObject:
requires no manual memory management calls.
HTH