ios開発——ノート編
7025 ワード
1 1:
2 BOOL isopen = !isopen; //View
3 @property (nonatomic, assign) BOOL open;//
4 self.group.open = !self.group.isopen; //View View
5 retun model.open?model.friend.count:0
6
7 2:
8 //View ——@interface
9 @class iCocosView
10 @protocol iCocosDelegate <NSObject>
11 @optional
12 -(void)headerView:(iCocosView *)view;
13 @end
14 //View
15 @property (nonatomic, assign) id<iCocosDelegate> delegates;
16 //
17 if([self.delegate respondsToSelector:@selector(headerView:)]) {
18 [self.delegate headerView:self];
19 }
20 //
21 < >/x.delegate = self;
22 //
23 -(void)headerView:(iCocosView *)view {
24 [self.tableView reloadData];
25 }
26
27 3:Block
28 // Block
29 typedef void(^iCocosBlock) (id);
30 @property (nonatomic, copy) iCocosBlock block;
31 // Block
32 if(self.block) {
33 self.block(self);
34 }
35 // Block
36 header.block = ^(id sender) {
37 [self.tableView reloadData];
38 }
39
40 4:
41 //
42 [[NSNotificationCenter defaultCenter] addobserver:self selector:@selector(click) name:@"friends" object:nil];
43 //
44 -(void)click {
45 [self.tableView reloadData];
46 }
47 //
48 [[NSNotificationCenter defaultCenter] postNotificationName:@"friends" object:self userInfo:nil];
49 // :( viewDidDisappear)
50 -(void)dealloc {
51 // ARC [super dealloc];
52 [[NSNotificationCenter defaultCenter] removeObserver];
53 }