I’ve mentioned a number of resources for working with blocks since they were introduced in iOS 4 such as this massive collection of objective-c block utilities. Blocks are a great addition but there are some issues that can come up especially when using blocks based handlers with NSNotificationCenter.
When using blocks with because you’re no longer manually cleaning up your observers from the notification center when the object deallocs you’ll need to use other techniques to make sure everything is properly cleaned up.
Here’s a nice guide from Erica Sadun explaining some of the dangers when using blocks based NSNotification centers and how to avoid them.
Specifically the tutorial goes into some key rules to follow when using notification handler blocks, and how to properly create short-term observers for those times when you want to remove a oberserver as soon as some event triggers.
You can find the tutorial over on the Informit site.
A nice guide for avoiding problems when using blocks and NSNotificationCenter.
- NSNotificationCenter Category Providing An Easier Blocks Based API Without The Memory Issues
- Library Providing An NSNotificationCenter Alternative For Handling Multiple Delegates
- Tutorial: Objective-C Blocks (Closures) For Beginners
- Handy Cheat Sheet For Using Objective-C Blocks (Closures)
- Blocks – An Interesting Objective-C Addition In iOS 4
Original article: Tutorial: How To Avoid Issues When Using Blocks With NSNotificationCenter
©2014 iOS App Dev Libraries, Controls, Tutorials, Examples and Tools. All Rights Reserved.




