Get Updates By E-mail 

Article Written By:
Johann Dowa

Open Source Library Providing A Swift Based Alternative To NSNotificationCenter

  •  
  •  
  •  
  •  
  •  

I’ve mentioned a few libraries for simplifying work with NSNotificationCenter, most recently FXNotifications which provides an objective-c category adding a blocks based API and reducing memory related issues.

Here’s an open source library from Alec Larson providing a Swift based alternative to NSNotificationCenter with a very clean and simple syntax.

This example from the readme shows how simple it is to create a generic emitter with EmitterKit:

let didLogin = Event<user>()

didLogin.once { user in
  println("Successfully logged in as &#40;user.name)!")
}

didLogin.emit(user)

The advantages of EmitterKit as stated in the readme include:

No longer be forced to typecast event data in your closures.
No longer be forced to removeObserver in your classes’ deinit methods.
Backwards-compatible with NSNotificationCenter (like UIKeyboardWillShowNotification)!
Simpler syntax

You can find Emitter-Kit on Github here.

A nice easy to use swift based library for working with 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