我从静态分析器中得到这个错误:
这是代码:
API Misuse (Apple) - Dictionary cannot be nil
- (NSString *)description
{
return [@{@"filePath": self.filePath,
@"fileName": self.fileName,
@"fileAttributes": self.fileAttributes,
@"creationDate": self.creationDate,
@"modificationDate": self.modificationDate,
@"fileSize": @(self.fileSize),
@"age": @(self.age),
@"isArchived": @(self.isArchived)} description];
}
谁能告诉我问题出在哪里?
最佳答案
那段代码看起来像是来自 Lumberjack 的 DDFileLogger.m 的旧版本
他们通过在字典中的项目为 nil 时插入默认的空字符串来消除警告 -> https://github.com/CocoaLumberjack/CocoaLumberjack/pull/127/files
return [@{@"filePath": (self.filePath ?: @""),
@"fileName": (self.fileName ?: @""),
@"fileAttributes": (self.fileAttributes ?: @""),
@"creationDate": (self.creationDate ?: @""),
@"modificationDate": (self.modificationDate ?: @""),
@"fileSize": @(self.fileSize),
@"age": @(self.age),
@"isArchived": @(self.isArchived)} description];
关于ios - 来自静态分析器的 API 滥用错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20453619/