I'm using NSDictionary to change the appearance of UIBarButtonItem in the appDelegate file:
UIBarButtonItem *barButtonItemProxy = [UIBarButtonItem appearanceWhenContainedIn:
[UINavigationBar class], [UINavigationController class], nil];
NSDictionary *textAttributes = @{UITextAttributeFont :
[UIFont fontWithName:@"ChocoBold" size:13.0f],
UITextAttributeTextColor : [UIColor whiteColor],
UITextAttributeTextShadowColor : [UIColor blackColor],
UITextAttributeTextShadowOffset : [NSValue valueWithUIOffset:UIOffsetMake(0.0f, -1.0f)]
};
[barButtonItemProxy setTitleTextAttributes:textAttributes forState:UIControlStateNormal];
The app works fine in the simulator but when I run it on a device the app crashes with the following exception:
[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]
The crash happens in NSDictionary *textAttributes line.
I don't understand which parameter is nil in that dictionary?
[UIFont fontWithName:@"ChocoBold" size:13.0f]ChocoBoldfont in your project? If not try adding it.UIFont fontWithName:@"ChocoBold" size:13.0f]and it shows null. I have ChocoBold added to my project, I added it to the plist under "Fonts provided by application" and added it to the Build Phases. Also, I'm using it across my app and it works fine.