I am customizing the UINavigationBar of an iOS app under iOS 6. Thus, I am using the setTitleTextAttributes to do so.
However the specific setting
NSDictionary *attribute = @{UITextAttributeFont : [UIFont fontWithName:@"Bernard MT Condensed" size:21.0]};
causes the app to crash on a device, but not in the Simulator, with the following exception:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]:
attempt to insert nil object from objects[0]'
I found this question which seems to be of the same kind, but both my device and my simulator are set to the exact same regional settings (language, region format).
A fact worth noting is that the regional settings are set to American English in both environments, but I am showing text in a Danish regional format with danish special characters, however, it does work on the simulator, as noted.
The font you are using is a custom font which requires font files to be added to the app’s resources and an entry in the Info.plist.
Filename case matters on real devices, but not the simulator. You need to make sure that the entry in the Info.plist matches the real filename (including case) of the actual font files.
Side note for those that think using the Simulator is enough – This is one of the many reasons that testing on a real device is critical.