通知&代理

通知:多对多的关系,比较耗性能

使用:
1.观察者到通知中心注册(接受那个发布者发布的什么通知,监听到通知后的处理方法)
 [[NSNotificationCenter defaultCenter] addObserver:selfselector:@selector(keyBoardShow:) name:UIKeyboardDidShowNotification object:nil];
2.移除观察者

    [[NSNotificationCenter defaultCenter] removeObserver:self];



 
代理:一对一的关系,性能较好,与继承相比较耦合性大大降低
原文地址:https://www.cnblogs.com/lijianyi/p/4278429.html