Repository navigation
Expand file tree
/
Copy pathFGTypes.m
More file actions
83 lines (63 loc) · 1.5 KB
/
Copy pathFGTypes.m
File metadata and controls
83 lines (63 loc) · 1.5 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//
// FGTypes.m
// FastGuiKit
//
// Created by 易元 白 on 15/3/5.
// Copyright (c) 2015年 eldereal. All rights reserved.
//
#import <objc/runtime.h>
#import "FGTypes.h"
static void * ReuseIdPropertyKey = &ReuseIdPropertyKey;
static void * NotifyHolderPropertyKey = &NotifyHolderPropertyKey;
@implementation FGNotifyCustomViewResultHolder
+ (FGNotifyCustomViewResultHolder *) holderWithBlock: (FGVoidBlock) block
{
FGNotifyCustomViewResultHolder *holder = [[FGNotifyCustomViewResultHolder alloc] init];
holder.block = block;
return holder;
}
-(void)notify
{
if (self.block != nil) {
self.block();
}
}
@end
@implementation FGStyleBlockHolder
+ (FGStyleBlockHolder *) holderWithBlock: (FGStyleBlock) block
{
FGStyleBlockHolder *holder = [[FGStyleBlockHolder alloc] init];
holder.block = block;
return holder;
}
-(void)notify: (UIView *) view;
{
if (self.block != nil) {
self.block(view);
}
}
@end
@implementation FGVoidBlockHolder
+ (FGVoidBlockHolder *) holderWithBlock: (FGVoidBlock) block
{
FGVoidBlockHolder *holder = [[FGVoidBlockHolder alloc] init];
holder.block = block;
return holder;
}
-(void)notify
{
if (self.block != nil) {
self.block();
}
}
@end
@implementation UIView (FastGui)
- (void)setReuseId:(NSString *)reuseId
{
objc_setAssociatedObject(self, ReuseIdPropertyKey, reuseId, OBJC_ASSOCIATION_COPY_NONATOMIC);
}
- (NSString *)reuseId
{
return objc_getAssociatedObject(self, ReuseIdPropertyKey);
}
@end