Latest 1.3.1
License MIT
Platforms ios 9.0

A new advance NotificationCenter by Swift


pod 'SwiftyNotification'

// Before:


NotificationCenter.default.addObserver(forName: NSNotification.Name(rawValue: "SomeChange"), object: nil, queue: nil) { (noti) in
    guard let info = noti.userInfo else { return }
    // info["Some hard to remember key"] ....
    // What's the type I need ?

NSNotificationName make me go crazy. It’s too troublesome.

What’s the content of userinfo , What’s the key and What I want? It must take your much time.

Notification Poster NSNotification.Name("SomeChange"), object: nil, userInfo: ["What's the key": someValue])

When you want to post a notification. You had to search the NotificationName of the notification. And then, You have to find the corresponding Key of userinfo.

I want to be simple


You just need creat a struct for one Notification.

You can assign the type of notification’s userinfo with the help of protocol.

You no longer need to guess what’s the info in the notification

struct MarketChangeNoti: INewNotifioncation {
    typealias InfoType = (name: String, age: Int)
    static var name: String = "marketChangeNoti"


NewNotifications.MarketChangeNoti.addObserve(notiDispose, response: ((name: String, age: Int)) -> ())
// info's type is a Tuple which contain String and Int, we also know the meaning of info

MarketChangeNoti.addObserve(notiDispose) { (result) in
    print(, "3232" , result.age)

Notification Poster (name: String, age: Int)

At a glance, the notification info need name and age

Remove Notifications

var notiDispose = NewNotiDispose()




Latest podspec

    "name": "SwiftyNotification",
    "version": "1.3.1",
    "summary": "A new advance NotificationCenter by Swift.",
    "description": "A new advance NotificationCenter by Swift, more convenience",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "zhouzf": "[email protected]"
    "platforms": {
        "ios": "9.0"
    "swift_version": "4.0",
    "source": {
        "git": "",
        "tag": "v1.3.1"
    "source_files": "Classes/*"

Pin It on Pinterest

Share This