Latest 2.0.1
Homepage https://github.com/mohamede1945/KVOController-Swift
License MIT
Platforms ios 8.0, requires ARC
Authors

Version
License
Platform

Supports Swift 3.0

Have you ever wondered if you can implement a generic key-value observing for Swift. It makes your life easy and saves you a lot of casting.
This project is inspired by facebook/KVOController. So, it doesn’t only provide a neat API for KVO’, but also makes use of Swift generics feature.

Requirements

  • iOS 7.0+ / Mac OS X 10.9+
  • Xcode 8
  • Swift 3.0

Usage

Simple use

observe(retainedObservable: clock, keyPath: "date", options: .New | .Initial)
    { [weak self] (observable: Clock, change: ChangeData<NSDate>) -> () in

        if let date = change.newValue {
            self?.timeLabel.text = formatter.stringFromDate(date)
        }
}

Note, you have to give the change a generic type of the property. In our case property is NSDate, so change is of type ChangeData<NSDate>

You can make use of automatic unobserving behavior or if you really want to unobserve, simply call

  unobserve(clock, keyPath: "date")

Installation

KVOController-Swift is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "KVOController-Swift"

For iOS 7.x:

Embedded frameworks require a minimum deployment target of iOS 8.

To use KVOController-Swift with a project targeting iOS 7, you must include KVOController.swift directly into your project.

Author

Mohamed Afifi, [email protected]

License

KVOController-Swift is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "KVOController-Swift",
    "version": "2.0.1",
    "summary": "Generic, simple key-value observing for Swift",
    "description": "**Supports Swift 3.0**nnHave you ever wondered if you can implement a generic key-value observing for Swift. It makes your life easy and saves you a lot of casting.nThis project is inspired by facebook/KVOController. So, it doesn't only provide a neat API for KVO', but also makes use of Swift generics feature.",
    "homepage": "https://github.com/mohamede1945/KVOController-Swift",
    "license": "MIT",
    "authors": {
        "Mohamed Afifi": "[email protected]"
    },
    "source": {
        "git": "https://github.com/mohamede1945/KVOController-Swift.git",
        "tag": "2.0.1"
    },
    "social_media_url": "https://twitter.com/mohamede1945",
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "source_files": "Sources/**/*"
}

Pin It on Pinterest

Share This