Latest 0.5.0
Homepage https://github.com/ML-Works/KVO-MVVM
License MIT
Platforms ios 7.0, requires ARC
Authors ,

CI Status
Version
License
Platform

Usage

  1. First #import <KVO-MVVM/KVOUIView.h> or any other available header
  2. Subclass your custom view from KVOUIView
  3. Use mvvm_observe:with: or mvvm_observeCollection:with: like this:

     - (instancetype)initWithFrame:(CGRect)frame {
         if (self = [super initWithFrame:frame]) {
    
             [self mvvm_observe:@keypath(self.viewModel.title)
                           with:^(typeof(self) self, NSString *title) {
                 self.titleLabel.text = self.viewModel.title;
             }];
    
             [self mvvm_observeCollection:@keypath(self.viewModel.values)
                                     with:^(typeof(self) self,
                                            NSArray<NSNumber *> *value,
                                            NSKeyValueChange change,
                                            NSIndexSet *indexes) {
                 // ...
             }];
    
         }
         return self;
     }
  4. Do not unobserve any KVO-observings any more

Observing keypaths with weak properties in it is not supported.

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

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

pod 'KVO-MVVM'

Authors

Anton Bukov, [email protected]
Andrew Podkovyrin, [email protected]

License

KVO-MVVM is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "KVO-MVVM",
    "version": "0.5.0",
    "summary": "KVO binding especially for ViewModel observing by View",
    "description": "Simply observe ViewModel changes by View layer using block-basednsyntax over vanilla Cocoa KVO. The main idea is to observe keypathsnlike this one - @keypath(self.viewModel.state) and not to unsubscribe.",
    "homepage": "https://github.com/ML-Works/KVO-MVVM",
    "license": "MIT",
    "authors": {
        "Anton Bukov": "[email protected]",
        "Andrew Podkovyrin": "[email protected]"
    },
    "source": {
        "git": "https://github.com/ML-Works/KVO-MVVM.git",
        "tag": "0.5.0"
    },
    "social_media_url": "https://twitter.com/k06a",
    "platforms": {
        "ios": "7.0"
    },
    "requires_arc": true,
    "source_files": "Pod/Classes/*.{h,m,mm}",
    "private_header_files": "Pod/Classes/SuperKVOPrivateImplementation.h"
}

Pin It on Pinterest

Share This