Latest 1.1.1
License Apache License, Version 2.0
Platforms osx 10.13, ios 10.0, tvos 10.0
Frameworks Foundation

Swift Event Center

Build Status


Swift Event Center to create custom events and respond to them.

The idea was to build a simple event center from scratch to:

  • better understand how a notification/event center would work
  • have simple event manager for simple tasks
  • in pure Swift
  • and not use Apple’s Notification Center

The interesting thing about the process is that while building it, I got a deeper understanding of how Notification Center.

To make it easier for new comers, I decided to keep Apple’s way of naming things.

Note: EventCenter is not meant to be a full replacement of Notification Center. It is a simpler alternative (as in "simpler to use, but also simpler in terms of functionalities") that should be good enough for simple projects.


EventCenter allows you to:

  • [x] – add observer for Event.Name (a.k.a. Notification.Name)
  • [x] – specify a name for added observers so that they can be removed independently
  • [x] – remove all observers for a specific Event.Name
  • [x] – remove one observer with a specific name for a specific Event.Name
  • [x] – post events and pass object:Any? & userInfo:[AnyHashable:Any]?
  • [ ] – specify priority for each observer (not implemented yet)


With SPM, add the following to the dependencies of your Package.swift

.package(url: "", from: "1.0.0")


Event is just a typealias for Notification.

See Examples & Tests for more information.

import EventCenter

let ec = EventCenter()


ec.addObserver(forEvent: Event.Name("event1"), name: "obs1", callback: { event: Event in 

    if let obj = event.object {
        print("Hello, (obj)!") 


... Event.Name("event1"), object: "World")


Made with ❤️ by:


Apache 2.0 @ Ladislas de Toldi

Original Work

This project is based on great people’s ideas. The original idea was created by Stephen Haney. It was then improved by Robin Walter‘s Swift-Events. First I wanted to fork Robin’s repo but after spending a couple of hours on it, I decided to rewrite most of it. Original work from Stephen Haney & Robin Walter is under MIT.

Latest podspec

    "name": "SwiftEventCenter",
    "version": "1.1.1",
    "summary": "Swift Event Center to create custom events and respond to them",
    "homepage": "",
    "license": {
        "type": "Apache License, Version 2.0"
    "authors": "Ladislas de Toldi",
    "module_name": "EventCenter",
    "swift_version": "4.2",
    "platforms": {
        "osx": "10.13",
        "ios": "10.0",
        "tvos": "10.0"
    "source": {
        "git": "",
        "tag": "1.1.1"
    "source_files": "Sources/*.swift",
    "pod_target_xcconfig": {
        "SWIFT_VERSION": "4.2"
    "frameworks": "Foundation"

Pin It on Pinterest

Share This