iphone - [__NSCFNumber length]: unrecognized selector sent to instance -
i trying pass data table view controller detail view controller. every entry of table works should, except one. here prepareforsegue method:
- (void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender{ if ([[segue identifier] isequaltostring:@"showdetails"]) { nsindexpath *indexpath = [[self tableview] indexpathforselectedrow]; nsdictionary *notification = [[self notifications] objectatindex:[indexpath row]]; nrdetailviewcontroller *destviewcontroller = [segue destinationviewcontroller]; [destviewcontroller setdate:[notification objectforkey:@"date"]]; [destviewcontroller setfrom:[notification objectforkey:@"from"]]; [destviewcontroller setiden:[notification objectforkey:@"identifier"]]; [destviewcontroller setpriority:[notification objectforkey:@"priority"]]; [destviewcontroller setsubject:[notification objectforkey:@"subject"]]; [destviewcontroller setmessage:[notification objectforkey:@"text"]]; } }
here interface detail view:
#import <uikit/uikit.h> @interface nrdetailviewcontroller : uiviewcontroller @property (weak, nonatomic) iboutlet uitextfield *datefield; @property (weak, nonatomic) iboutlet uitextfield *fromfield; @property (weak, nonatomic) iboutlet uitextfield *idenfield; @property (weak, nonatomic) iboutlet uitextfield *priofield; @property (weak, nonatomic) iboutlet uitextfield *subjectfield; @property (weak, nonatomic) iboutlet uitextview *messageview; @property (copy, nonatomic) nsstring *date; @property (copy, nonatomic) nsstring *from; @property (copy, nonatomic) nsstring *iden; @property (copy, nonatomic) nsstring *priority; @property (copy, nonatomic) nsstring *subject; @property (copy, nonatomic) nsstring *message; @end
here detail view's implementation file:
#import "nrdetailviewcontroller.h" @interface nrdetailviewcontroller () @end @implementation nrdetailviewcontroller - (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil { self = [super initwithnibname:nibnameornil bundle:nibbundleornil]; if (self) { // custom initialization } return self; } - (void)viewdidload { [super viewdidload]; [[self datefield] settext:[self date]]; [[self fromfield] settext:[self from]]; [[self idenfield] settext:[self iden]]; [[self priofield] settext:[self priority]]; [[self subjectfield] settext:[self subject]]; [[self messageview] settext:[self message]]; } - (void)didreceivememorywarning { [super didreceivememorywarning]; // dispose of resources can recreated. } @end
i have problem setting text of idenfield text of iden. have added exception breakpoint, , got exception indeed occurs @ line:
[[self idenfield] settext:[self iden]];
at point, have printed value of [self iden] , contains content want pass, have absolutely no idea problem is, since said, other fields working should.
the exception being thrown is:
2013-08-07 22:28:20.539 notificationreader[1214:11303] -[__nscfnumber length]: unrecognized selector sent instance 0x7587a00
any appreciated greatly.
it looks like:
[destviewcontroller setiden:[notification objectforkey:@"identifier"]];
is returning nsnumber , not nsstring. try replacing line with:
[destviewcontroller setiden:[(nsnumber*)[notification objectforkey:@"identifier"] stringvalue]];
Comments
Post a Comment