ios开发——笔记篇

 :开关
     BOOL isopen = !isopen; //View
     @property (nonatomic, assign) BOOL open;//模型属性
     self.group.open = !self.group.isopen; //View修改上面的View中的代码
     retun model.open?model.friend.count:

 :代理
     //View中——@interface之前
     @class iCocosView
     @protocol iCocosDelegate <NSObject>
     @optional
     -(void)headerView:(iCocosView *)view;
     @end
     //View中属性
     @property (nonatomic, assign) id<iCocosDelegate> delegates;
     //代理方法是否响应
     if([self.delegate respondsToSelector:@selector(headerView:)]) {
         [self.delegate headerView:self];
     }
     //遵守协议
     <协议>/x.delegate = self;
     //实现代理方法
     -(void)headerView:(iCocosView *)view {
         [self.tableView reloadData];
     }

 :Block
     //定义Block
     typedef void(^iCocosBlock) (id);
     @property (nonatomic, copy) iCocosBlock block;
     //响应Block
     if(self.block) {
         self.block(self);
     }
     //实现Block
     header.block = ^(id sender) {
         [self.tableView reloadData];
     }

 :通知
     //添加通知
     [[NSNotificationCenter defaultCenter] addobserver:self selector:@selector(click) name:@"friends" object:nil];
     //实现通知方法
     -(void)click {
         [self.tableView reloadData];
     }
     //注册通知
     [[NSNotificationCenter defaultCenter] postNotificationName:@"friends" object:self userInfo:nil];
     //移除通知:(还可以在viewDidDisappear)
     -(void)dealloc {
         //非ARC中必须使用  [super dealloc];
         [[NSNotificationCenter defaultCenter] removeObserver];
     }
 
上一篇:centos7搭建python3并和python2共存


下一篇:nfs挂在内核出错 T T *** ERROR: Cannot umount