比较始终是真实的
问题描述:
我在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之前,该通知不存在。
代码已有几年了,现在框架中不支持iOS 5,所以我将删除该支票。
更新 原来检查无法删除,因为我们仍然支持OS X 10.7。所以我添加了#pragmas来消除警告。
+0
谢谢!我的应用程序仅适用于iOS,并且支持iOS7及更高版本,无OS X - 所以我只是要删除该行......! – Kreuzberg
答
的问题是,&NSUbiquityIdentityDidChangeNotification
是变量的地址,它不能为空。 条件if (&NSUbiquityIdentityDidChangeNotification != NULL)
始终值为true,并且Xcode警告您该行无用。
除非您尝试支持iOS 5,否则不需要检查'NSUbiquityIdentityDidChangeNotification'常量。 – rmaddy