SwiftNotes
A super simple wrapper around NotificationCenter
Install / Use
/learn @sobri909/SwiftNotesREADME
SwiftNotes
A super simple wrapper around NotificationCenter.
Setup
pod 'SwiftNotes'
Or just drop SwiftNotes.swift into your project.
UIKit Notification Examples
UIKeyboard Notifications
when(.UIKeyboardDidShow) { note in
// do stuff
}
UIApplication Notifications
when(.UIApplicationDidBecomeActive) { _ in
// do stuff
}
Custom Notifications
Define A Custom Notification
// define the custom event name
extension NSNotification.Name {
static let somethingHappened = Notification.Name("somethingHappened")
}
Trigger Your Custom Notification
// send your custom event
trigger(.somethingHappened)
Respond To Your Custom Notification
when(.somethingHappened) { _ in
// do stuff
}
Extra Parameters
Trigger An Event And Include UserInfo
trigger(.somethingHappened, userInfo: ["goodTimes": true])
Trigger An Event On A Specific Sender
trigger(.updatedFromRemote, on: self)
Observe An Event On A Specific Sender
when(model, does: .updatedFromRemote) { _ in
// do stuff
}
Respond On A Specific Queue
// make sure the closure is run on the main queue
when(.somethingHappened, doOn: OperationQueue.main) _ in
// do stuff
}
Related Skills
node-connect
353.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
111.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
353.3kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
353.3kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
