In swift 3 there are a lot of major changes in the syntax, and the norms that we used. In my opioion a better one, the code is shorter, and there are less primitive passing around. As in this very case NSNotificationCenter is getting a face lift! So here is how I exploit the new Notification.Name in swift 3

The Ancient Way

In swift 2, when you try to pass things around we always orbit around the concept of passing through the NSNotificationCenter.defaultCenter().post("someStringThatShouldBeDeclared")

Which is actually up to author of the code whether they will declare it as Single Point of Control or not. Declare a let on top of the file is a norm I guess, but I always try to use enum to handle it so that you can know the complete list of available of the Notification that available in the complete system.

The New Way

In Swift 3, even though the system still use the same backbone, where at the end the String is passing through as a NotificationName. But in Swift3 they introduce an awesome way to handle it. By required the method, ..) instead of primitive string. So how is this ever be good? as it would need you to introduce another wrap before you can simply passing down the string you already have in mind?

The answer is extension. So normally you would need to do something like this to get it donw:

But then this has no concept of Single point of control at all, and you will easily lost your track. Especially in very large project.

So with extension, you would be able to accomplish something like this.

This way every single time you ask for auto complete from Xcode, it will gave you the complete list of Notification.Name that already declared and reduce the possibility of redundant notifications.

To even shorten the code. You can do something like this.

Hope this will be a great help, please let me know what you think!

Anyway here is the complete snippet.