Izeni's Common iOS Code http://www.izeni.com/
This project contains several miscellaneous utilities.
- Easier to use than NSNotificationCenter
- Objective-C and Swift support
- Automatic removal of listeners upon dealloc; no need to call removeObserver(self)
- Events are identified by UUIDs, which are less likely to collide than user-defined keys
- Events are delivered on the main thread, making GUI updates worry-free
- Events are delivered asynchronously to guarantee correctness, but there is a synchronous option available for those corner cases
class LoginService {
static let userDidLogout = NSUUID() // This is the broadcast ID
static var userID: String?
class func logout() {
...
// Will call method on LocationTracker and any other monitoring instances.
Broadcast.emit(userDidLogout, value: userID) // Async, main thread delivery
}
}
...
class LocationTracker: NSObject {
static let singleton = LocationTracker()
static func start() {
singleton // static let vars are lazy instantiated; this initializes the singleton
}
init() {
...
// The selector must be an instance method, as class/static functions aren't supported.
monitorBroadcast(LoginService.userDidLogout, selector: "stop")
}
func stop() {
...
}
ios-pod-test is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'Izeni', :git => 'https://dev.izeni.net/izeni/izcommon.git'
If you wish to co-develop this pod with your project, add this line to your Podfile instead of the one above:
pod 'Izeni', :path => '~/path/to/this/project'
Be sure that your Podfile has the following line too:
use_frameworks!
Bryan Henderson, Thane Brimhall, Jacob Ovard, Taylor Allred, Skyler Smith, Matthew Bailey
Izeni's Common iOS Code is available under the MIT license. See the LICENSE file for more info.