-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAIMObserver.h
More file actions
25 lines (20 loc) · 864 Bytes
/
AIMObserver.h
File metadata and controls
25 lines (20 loc) · 864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//
// AIMObserver.h
//
// Created by Maciej Gad on 29.07.2015.
// Copyright (c) 2015 All in Mobile. All rights reserved.
//
#import <Foundation/Foundation.h>
/**
helper class for KVO, used as alternative for `[obj addObserver:self forKeyPath:keyPath options:NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld|NSKeyValueObservingOptionInitial context:NULL];`, it is guaranteed that observer is removed when object is deallocated
*/
@interface AIMObserver : NSObject
/**
observed object `obj` for `keyPath` and call block passed as `onChange` parameter, *remember to use `weak` pointer to `self` within this block*
@param obj obj
@param keyPath key path
@param onChange on change
*/
+ (instancetype)observed:(NSObject *)obj keyPath:(NSString *)keyPath onChange:(void(^)(NSDictionary *change))onChange;
- (instancetype)init NS_UNAVAILABLE;
@end