当我创建一个自定义导航栏类和定制它的使用下面的代码title属性:的iOS:“试图插入从对象无对象[1]”创建字典
self.titleTextAttributes = @{ UITextAttributeFont: bariol,
UITextAttributeTextColor: [UIColor whiteColor]
};
然而,当我运行该代码,则它返回下列错误消息:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[1]'
我使用的Xcode 4.6和在设备上运行使用的是iOS 6.
这并不是那么严格,它只是认为如果在预期关键时发现'nil',参数就会停止。值得注意的是,如果你传递一个'nil'对象,你会得到完全相同的异常。 – 2013-02-26 22:34:29
@KevinBallard废话。从[[NSDictionary dictionaryWithObjectsAndKeys:@“a”,@“a”,nil,@“b”,nil];'?它停止阅读第一个零对象参数。 – justin 2013-02-26 22:51:58
对不起,我说的对象,当我说的关键(倒装方法)。它无法区分'nil'对象和sentinel'nil'。尝试使用'nil'作为键,看看我的意思:'[NSDictionary dictionaryWithObjectsAndKeys:@“anObj”,@“aKey”,@“anotherObj”,nil,nil]'。 – 2013-02-26 22:54:42