Reputation: 5857
I'm creating a custom navigation bar class and customizing it's title attributes using the following code:
self.titleTextAttributes = @{ UITextAttributeFont: bariol,
UITextAttributeTextColor: [UIColor whiteColor]
};
However, when I run the code, it returns the following error message:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[1]'
I'm using Xcode 4.6 and running on a device using iOS 6.
Upvotes: 13
Views: 21676
Reputation: 3716
This error seems to be somewhere else. It's pointing to an array error at object '1'. In your case you have a dictionary and object '1' is UITextAttributeTextColor: [UIColor whiteColor]
which will never be nil.
Upvotes: 5
Reputation: 104698
The parameters of the literals (values and keys of your dictionary) must not be nil
.
If you prefer a constructor which is less strict, you might consider using +[NSDictionary dictionaryWithObjectsAndKeys:]
instead.
Upvotes: 7
Reputation: 185681
It sounds like your bariol
object is nil
. You can't store nil
in a dictionary.
Edit:
Actually, are you sure that's the right line of code? Your error references NSPlaceholderArray
, which suggests it's a problem with a @[]
literal, not a @{}
literal.
Upvotes: 11