Skip to content

Latest commit

 

History

History
17 lines (9 loc) · 1.15 KB

README.md

File metadata and controls

17 lines (9 loc) · 1.15 KB

TypedNotification: Strongly typed notifications in Swift

Notifications are a common communication mechanism on Apple platforms, but their API is stringly-typed and uses a Dictionary to carry extra information, both of which mean that failures are totally silent. That ain't Swifty!™

TypedNotification provides a wrapper around Foundation.NotificationCenter that lets the compiler help you out. It removes the magic strings, and provides a strongly typed way to send extra data.

TypedNotification is implemented as a protocol. Just make your enums conform, and BAM you're done.

This repo

This repo contains an Xcode playground demonstrating the use of TypedNotification. Launch the playground, and poke around the Sources folder. You're free to also use the pug-themed code.

This repo also contains the presentation I gave at SLUG (video forthcoming).

Suggestions?

Make a PR! I've already improved this code several times while writing the presentation, so there's surely more ways to make it better.