A thread-safe and type-safe block-based wrapper for Key-Value Observing in Swift and Objective-C.
PMKVObserver is a modern, block-based wrapper around Apple's Key-Value Observing (KVO) API for iOS, macOS, watchOS, and tvOS development. It provides a safer and more convenient alternative by eliminating common pitfalls like manual observer removal, thread-safety issues, and dangling references. The library offers automatic cleanup when observed or observing objects deallocate and includes strong typing support in Swift.
iOS, macOS, watchOS, and tvOS developers using Objective-C or Swift who need to implement Key-Value Observing in their applications. It is particularly useful for developers who have experienced crashes or complexity with native KVO APIs and want a more maintainable solution.
Developers choose PMKVObserver over native KVO because it provides thread-safe observer registration and cancellation, automatic unregistering to prevent crashes, and a block-based API that improves code readability. Its unique selling point is the combination of safety features like automatic cleanup with strong typing in Swift using KeyPath, reducing runtime errors.
Modern thread-safe and type-safe key-value observing for Swift and Objective-C
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Observers can be registered, notified, and cancelled from different threads safely, even simultaneously, as explicitly stated in the README's key features.
Prevents crashes by automatically unregistering KVO when the observed object deallocates, and supports an observing object for auto-unregistration, simplifying cleanup.
Uses Swift KeyPath for type-safe APIs, reducing runtime errors and improving code clarity, with enhanced support for RawRepresentable types in recent versions.
Employs closures instead of selectors for callbacks, making code more readable and maintainable in both Objective-C and Swift, as shown in the examples.
The README explicitly admits nested key paths are not supported, requiring manual cancellation and limiting use for complex data modeling scenarios.
The repository is archived and forked, indicating no further maintenance from the original authors, which raises concerns about future updates and bug fixes.
Version history shows issues with specific Swift compiler versions (e.g., 5.1.5), requiring workarounds that add complexity and potential compatibility headaches.