Daily iOS
Architecture

Minimal NotificationCenter

This is a live coding exercise. Without Foundation's NotificationCenter, design and implement a small EventBus in Swift that subscribes and publishes by name. Tell me how you handle lifetime and the unsubscribe API so no handler is left behind after an observer goes away.

How would an interviewer hear this answer? You'll see whether they'd move on, dig in, or say no, and which sentences would trip you up. Your score doesn't change.
See the short answer

A dictionary of name to [subscription], subscribe returns a token, and observers are held weakly or removed when the token is released. When the token deinits, the subscription drops out on its own.

Share a question