-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBindingManager.m
More file actions
65 lines (45 loc) · 2 KB
/
BindingManager.m
File metadata and controls
65 lines (45 loc) · 2 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//
// BindingManager.m
// Bind
//
// Created by Ayal Spitz on 7/21/11.
// Copyright 2011 Ayal Spitz. All rights reserved.
//
#import "BindingManager.h"
static BindingManager *bindingManager = nil;
@implementation BindingManager
@synthesize bindings;
+ (BindingManager *)sharedManager{
if (bindingManager == nil) {
bindingManager = [[BindingManager alloc]init];
}
return bindingManager;
}
- (id)init
{
self = [super init];
if (self) {
self.bindings = [[NSMutableSet alloc]init];
}
return self;
}
+ (id)bind:(NSString *)dstPath of:(NSObject *)dst to:(NSString *)srcPath of:(NSObject *)src{
return [BindingManager bind:dstPath of:dst to:srcPath of:src withTransform:nil andValidation:nil];
}
+ (id)bind:(NSString *)dstPath of:(NSObject *)dst to:(NSString *)srcPath of:(NSObject *)src withTransform:(TransformBlock)block{
return [BindingManager bind:dstPath of:dst to:srcPath of:src withTransform:block andValidation:nil];
}
+ (id)bind:(NSString *)dstPath of:(NSObject *)dst to:(NSString *)srcPath of:(NSObject *)src withValidation:(ValidationBlock)block{
return [BindingManager bind:dstPath of:dst to:srcPath of:src withTransform:nil andValidation:block];
}
+ (id)bind:(NSString *)dstPath of:(NSObject *)dst to:(NSString *)srcPath of:(NSObject *)src withTransform:(TransformBlock)tBlock andValidation:(ValidationBlock)vBlock{
Bind *bind = [[Bind alloc]initWithSrc:src srcKeyPath:srcPath dst:dst andDstKeyPath:dstPath withTransform:tBlock andValidation:vBlock];
[[BindingManager sharedManager].bindings addObject:bind];
return bind;
}
+ (id)bindCollection:(NSString *)dstPath of:(NSObject *)dst to:(NSString *)srcPath of:(NSObject *)src withAdd:(AddBlock)aBlock andRemove:(RemoveBlock)rBlock{
CollectionBind *bind = [[CollectionBind alloc]initWithSrc:src srcKeyPath:srcPath dst:dst andDstKeyPath:dstPath withAdd:aBlock andRemove:rBlock];
[[BindingManager sharedManager].bindings addObject:bind];
return bind;
}
@end