解决方法
该委托是单一消息传递协议.如果要发送更改的多个对象,则需要使用NSNotifications.
您可以使用通知中心传递对象,如下所示:
NSDictionary *userInfo = @{@"myObject" : customObject}; NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; [nc postNotificationName:@"myNotificationString" object:self userInfo:userInfo];
想要收听通知时
[[NSNotificationCenter defaultCenter] addobserver:self selector:@selector(myCustomObserver:)name:@"myNotificationString" object:nil];
并设置选择器
-(void)myCustomObserver:(NSNotification *)notification{ CustomObject* customObject = notification.userInfo[@"myObject"]; }