Quantcast
Channel: Controls – TAGTECINFO
Viewing all articles
Browse latest Browse all 336

[iOS App Dev Libraries, Controls, Tutorials, Examples and Tools]NoticeObserveKit – A Swift Library That Simplifies Working With NSNotificationCenter

$
0
0

NoticeObserveKit is an open source Swift library submitted by Taiki Suzuki that provides a simpler syntax for working with NotificationCenter.

NoticeObserveKit provides a protocol which must be adhered to and then you can easily work with your observers.

This example of the readme demonstrations the creation of an observer pool with a couple of observers using NoticeObserveKit:

import UIKit
import NoticeObserveKit

class ViewController: UIViewController {
    private let searchBar = UISearchBar(frame: .zero)
    private var pool = NoticeObserverPool()

<pre><code>override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
    navigationItem.titleView = searchBar

    configureObservers()
}

private func configureObservers() {
    UIKeyboardWillShow.observe { [unowned self] in
        print("UIKeyboard will show = \($0)")
    }.addObserverTo(pool)

    UIKeyboardWillHide.observe { [unowned self] in
        print("UIKeyboard will hide = \($0)")
    }.addObserverTo(pool)
}
</code></pre>

}

You can find NoticeObserveKit on Github here.

A nice library for working with NotificationCenter in Swift.

Original article: NoticeObserveKit – A Swift Library That Simplifies Working With NSNotificationCenter

©2017 iOS App Dev Libraries, Controls, Tutorials, Examples and Tools. All Rights Reserved.

Reference source: iOS App Dev Libraries, Controls, Tutorials, Examples and Tools


Viewing all articles
Browse latest Browse all 336

Trending Articles