Skip to content

ML-Works/KVO-MVVM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KVO-MVVM

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;
   }
  1. 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, k06aaa@gmail.com Andrew Podkovyrin, podkovyrin@gmail.com

License

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published