【发布时间】:2013-11-27 04:07:04
【问题描述】:
我的字典的一个参数看起来是 nil,但我不知道为什么......我浏览了 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]'
【问题讨论】:
-
@MartinR 比你的评论。如果您将其发布为答案,我会接受。或者问题可能会作为重复而关闭。
-
错误,没有。重复的问题不需要接受答案。
-
@trojanfoe 这就是我写“或”的原因;)无论如何,投票结束我的问题。
标签: ios iphone objective-c