Get Updates By E-mail 

Article Written By:
Johann Dowa

Tutorial: How To Avoid Issues When Using Blocks With NSNotificationCenter

  •  
  •  
  •  
  •  
  •  

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.


  •  
  •  
  •  
  •  
  •  

Submit A Resource

Have you created a useful tutorial, library or tool for iOS development that you would like to get in front of our 300,000+ monthly page views from iOS developers?

You can submit the url here.

The resources we feel will appeal to our readers the most will be posted on the front page.

Comments