automatic-ref-counting
How to know if my Xcode iPhone project is using ARC?
Select your project, then Build Settings. Look for Objective-C Automatic Reference Counting in the Apple LLVM Compiler – Language section. Make sure you select the target; while you can set this in the project, the target can override it. (You can also use the search bar in Build Settings for OBJC_ARC.) Keep in mind, too, … Read more
Why does the ARC migrator say that NSInvocation’s -setArgument: is not safe unless the argument is __unsafe_unretained?
This is a complete guess, but might it be something to do with the argument being passed in by reference as a void*? In the case you’ve mentioned, this doesn’t really seem a problem, but if you were to call, eg. getArgument:atIndex: then the compiler wouldn’t have any way of knowing whether the returned argument … Read more
Objective C – Custom setter with ARC?
The strong takes care of itself on the ivar level, so you can merely do – (void)setMyObject:(MyObject *)anObject { _myObject = anObject; // other stuff } and that’s it. Note: if you’re doing this without automatic properties, the ivar would be MyObject *_myObject; and then ARC takes cares of the retains and releases for you … Read more
ARC __bridge modifiers demystified
Because I learned what they were and how they operated just recently, I want to share with anyone else who wishes to learn about the __bridge modifiers under ARC which can be a source of confusion due to the fact that toll-free bridging used to be accomplished with a simple cast. It used to be … Read more
Generic typeof for weak self references
In the latest clang version Apple clang version 4.0 (tags/Apple/clang-421.1.48) (based on LLVM 3.1svn), i.e. Xcode 4.4+, the __typeof__((__typeof__(self))self) trick is not necessary anymore. The __weak typeof(self) bself = self; line will compile just fine.
How do you remove KVO from a weak property?
I find any kind of code required specially for this case really unnecessary as removal can be automated. With the introduction of ARC, Apple should have provide automatic removal of observers that would fix cases like this, but unfortunately they didn’t. But I’ve made my own category that adds this lacking feature: https://github.com/krzysztofzablocki/SFObservers I’ve explained … Read more