我在Xcode 中收到此警告
comparison of addresses of NSUbiquitycontainerDidChangeNotification not equal to a null pointer is always true
它在的核心数据集成框架中
CDEICloudFileSystem.m
在中
- (void)addUbiquityContainerNotificationObservers {
[self removeUbiquityContainerNotificationObservers];
/// in this line
if (&NSUbiquityIdentityDidChangeNotification != NULL) {
///
__weak typeof(self) weakSelf = self;
ubiquityIdentityObserver = [[NSNotificationCenter defaultCenter] addObserverForName:NSUbiquityIdentityDidChangeNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
__strong typeof(weakSelf) strongSelf = weakSelf;
[strongSelf stopMonitoring];
[strongSelf willChangeValueForKey:@"identityToken"];
[strongSelf didChangeValueForKey:@"identityToken"];
}];
}
}
有人能告诉我怎么修吗?
感谢
我写了那个代码。正如一些人所指出的,在使用NSUbiquityIdentityDidChangeNotification
符号之前,它是为了确保它存在。在iOS 6之前,该通知不存在。
该代码已经有好几年的历史了,现在框架中不支持iOS5,所以我将删除检查。
更新事实证明,该检查无法删除,因为我们仍然支持OS X 10.7。所以我添加了#pragmas来消除警告。
问题是&NSUbiquityIdentityDidChangeNotification
是变量的地址,不能为NULL。条件if (&NSUbiquityIdentityDidChangeNotification != NULL)
的值始终为true,Xcode会警告您该行无效。