I've been chasing an exception for my UIPickerView for hours now. I've narrowed it down to one of the delegate methods, but honestly can't figure it out. All it's supposed to do is take the list of font families that comes natively on the iPhone and display their title in the picker view, in the font they represent.
-(NSAttributedString *)pickerView:(UIPickerView *)pickerView attributedTitleForRow:(NSInteger)row forComponent:(NSInteger)component
{
NSLog(@"attributedTitleForRow");
NSString *fontName = [self.fontFamilies objectAtIndex:row];
NSLog(@"Font: %@", fontName);
NSDictionary *attributes = @{NSFontAttributeName:fontName};
NSLog(@"Attributes: %@", attributes);
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:fontName attributes:attributes];
NSLog(@"Returning %@", attributedString);
return attributedString;
}
The Printout, incl. Exception:
2013-07-31 23:28:42.875 [4689:907] attributedTitleForRow
2013-07-31 23:28:42.876 [4689:907] Font: Thonburi
2013-07-31 23:28:42.879 [4689:907] Attributes: {
NSFont = Thonburi;
}
2013-07-31 23:28:42.881 [4689:907] Returning Thonburi{
NSFont = Thonburi;
}
2013-07-31 23:28:42.884 [4689:907] attributedTitleForRow
2013-07-31 23:28:42.886 [4689:907] Font: Snell Roundhand
2013-07-31 23:28:42.887 [4689:907] Attributes: {
NSFont = "Snell Roundhand";
}
2013-07-31 23:28:42.889 [4689:907] Returning Snell Roundhand{
NSFont = "Snell Roundhand";
}
2013-07-31 23:28:42.892 [4689:907] attributedTitleForRow
2013-07-31 23:28:42.894 [4689:907] Font: Academy Engraved LET
2013-07-31 23:28:42.896 [4689:907] Attributes: {
NSFont = "Academy Engraved LET";
}
2013-07-31 23:28:42.898 [4689:907] Returning Academy Engraved LET{
NSFont = "Academy Engraved LET";
}
2013-07-31 23:28:42.920 [4689:907] -[__NSCFConstantString screenFontWithRenderingMode:]: unrecognized selector sent to instance 0x3977f364
2013-07-31 23:28:42.922 [4689:907] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString screenFontWithRenderingMode:]: unrecognized selector sent to instance 0x3977f364'