I am getting this error from static analyzer :
This is the code :
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];
}
Can any one tell what is the problem ?
That chunk of code looks like it's from a older version of Lumberjack's DDFileLogger.m
They got rid of the warning by inserting default empty strings if nil for items in the dictionary -> 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];
Either one of your values is guaranteed to be nil, or one of your values is not an object pointer, because the following code yields no error at all:
- (NSString *)description
{
return [@{@"filePath": @"",
@"fileName": @"",
@"fileAttributes": @"",
@"creationDate": @"",
@"modificationDate": @"",
@"fileSize": @"",
@"age": @"",
@"isArchived": @""} description];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With