-[__nscfnumber Rangeofcharacterfromset:]: Unrecognized selector sent to instance 0x7fa5216589d0

Source: Internet
Author: User

This kind of mismatch, that is, the NSNumber type of the assignment to the string itself is not known, because my test, the code is as follows (VIEWCONTROLLER.M)

-(void) Viewdidload {
[Super Viewdidload];
BankAccount = [[Bankobject alloc] init];
[BankAccount setvalue:@ "ten" forkey:@ "account"];
[BankAccount addobserver:self forkeypath:@ "account" options:nskeyvalueobservingoptionnew| Nskeyvalueobservingoptionold Context:nil];

_mylabel = [[UILabel alloc] initwithframe:cgrectmake (100, 100, 200, 100)];
_mylabel.text = [BankAccount valueforkey:@ "account"];
_mylabel.textcolor = [Uicolor Whitecolor];
[Self.view Addsubview:_mylabel];

_mybutton = [UIButton buttonwithtype:uibuttontyperoundedrect];
_mybutton.frame = CGRectMake (200, 300, 100, 50);
_mybutton.backgroundcolor = [Uicolor Redcolor];
[_mybutton addtarget:self Action: @selector (ChangeAccount) forcontrolevents:uicontroleventtouchupinside];
[Self.view Addsubview:_mybutton];

}

Break point, is also the program after the execution of Viewdidload will not collapse, unaware of _mylabel.text = [BankAccount valueforkey:@ "Account"]; This error, changed to _mylabel.text = [ NSString stringwithformat:@ "%@", [BankAccount valueforkey:@ "Account"]; it's OK.

-[__nscfnumber Rangeofcharacterfromset:]: Unrecognized selector sent to instance 0x7fa5216589d0

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.