数组越界保护与消息传递black机制

时间:2021-07-20 06:38:53

数组越界保护
if(index.row <= [array count])

发送消息
[[NSNotificationCenter defaultCenter]
     postNotificationName:@"chuandi" object:self];
接收消息 自己写个action的动作
[[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(action)
                                                 name:@"chuandi" object:nil];
比如你在 一个子类里触发一个事件后   把消息传递到父类   在父类里的action 指向 推向另一个子类  就可以把

block机制
http://objccn.io/issue-7-4/

版本的判断
#define ISIOS7PLUS ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0 ? YES : NO)