cocoa touch - UIPickerView Exception -


i've been chasing exception uipickerview hours now. i've narrowed down 1 of delegate methods, can't figure out. it's supposed take list of font families comes natively on iphone , display title in picker view, in font 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 instance 0x3977f364 2013-07-31 23:28:42.922 [4689:907] *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[__nscfconstantstring screenfontwithrenderingmode:]: unrecognized selector sent instance 0x3977f364' 

the nsfontattributename has misleading name. expected value not font name uifont instance. need update code create uifont object based on font name get, , use uifont in attributes dictionary.

read docs nsfontattributename. tells you need uifont object, not nsstring.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -