Open Source:NSNotification And KVO Objective-C Categories For Automatic Observer Removal

ARC has been a great addition for developers using Objective-C almost completely eliminating any need for the dealloc method.  That being said if you employ the observer pattern you need to unregister before you release your observer object or suffer unwanted consequences.

That’s where this very useful collection of submitted categories come in.  These categories provide automatic removal for observers when the observer object is deallocated.

What’s really nice is that there is no need to change your code simply include the categories in your project, and you are good to go.  The categories work in both ARC and non-ARC apps.

The library is SFObservers from Kryzystof Zablocki and can be found on Github here.

You can read Kryzystof’s methodology in developing the categories on his site here.

This is extremely useful, as thanks to ARC and this category the need to create a dealloc method is now nearly eliminated.

Thanks to Krzystof for the submission.

©2012 iPhone, iOS 5, iPad SDK Development Tutorial and Programming Tips. All Rights Reserved.

.

DeliciousTwitterTechnoratiFacebookLinkedInEmail


Leave a Reply

Your email address will not be published. Required fields are marked *