在我的应用中执行以下操作不会致电代理人:
NSNetService * bonjourMonitor;
bonjourMonitor = [[NSNetService alloc] initWithDomain:@"local." type:@"_device-info._tcp" name:@"My Mac"];
[bonjourMonitor setDelegate:self];
[bonjourMonitor startMonitoring];
我正在使用自动参考计数。没有ARC做同样的工作是完美的。 NSNetService接缝在调用委托之前发布。
如何防止这种情况发生?
非常感谢!
答案 0 :(得分:1)
将bonjourMonitor定义为ivar或static。