我的字典的一个论点看起来是零,但我不知道为什么......我浏览了 SOF,所有的命题都是这样的。
CGSize size;
if ([[[UIDevice currentDevice] systemVersion]
compare:@"7.0" options:NSNumericSearch] == NSOrderedAscending) {
// here it works
size = [string sizeWithFont:[UIFont fontWithName:@"HelveticaNeue-Italic"
size:15.0f]];
} else {
// here it crashes
size = [string sizeWithAttributes:
[NSDictionary dictionaryWithObject:[UIFont fontWithName:@"HelveticaNeue-Italic"
size:15.0f] forKey:NSFontAttributeName]];
}
// 控制台输出
*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]:
attempt to insert nil object from objects[0]'