Next article: Friday Q&A 2012-04-13: Nib Memory Management
Previous article: Friday Q&A 2012-03-16: Let's Build NSMutableDictionary
Tags: arc code hack objectivec sourcecode
As a way of atoning for the lack of a Friday Q&A today, I'm pleased to introduce PLWeakCompatibility. Do you like ARC? Do you need to support older OS releases? Do you wish you could use
__weak variables on those older OSes? If so, then I have good news for you! PLWeakCompatibility is the solution you've been looking for.
Using PLWeakCompatibility is easy. Add one file to your Xcode project, add two compiler flags, and you're off to the races. If you have MAZeroingWeakRef in your app already, then PLWeakCompatibility will use it to handle weak references on older OSes. If you don't, then it will use its own implementation, which is considerably simpler but somewhat slower. When your app runs on a newer OS with built in weak reference support, PLWeakCompatibility passes all calls through to the native support.
As you can probably tell from the prefix, PLWeakCompatibility comes from my employer, Plausible Labs. I had a hand in writing it, but I didn't do it alone! You can now use
__weak on any OS where you can deploy ARC, so grab PLWeakCompatibility on GitHub now!
Comments RSS feed for this page
Add your thoughts, post a comment:
Spam and off-topic posts will be deleted without notice. Culprits may be publicly humiliated at my sole discretion.