Reputation: 17
how do I set a NSString using a value from a UILabel? so far i have this but it crashes:
NSString *theScore =[[NSString alloc]initWithFormat:@"%@",scoreX.text];
scoreX is a UILabel.
can anyone help? thanks in advance
Upvotes: 0
Views: 2918
Reputation: 3379
Your given code is correct. you don't try some other way.
let you try this,
NSString *theScore =[NSString stringWithFormat:@"%@",[scoreX text]];
Upvotes: 1
Reputation: 14326
Assuming you're using Interface Builder, it sounds like you may have bound the 'scoreX' outlet to a wrong element that doesn't have the text property.
If not, posting the text of the crash would help.
Upvotes: 0
Reputation: 3762
Have you checked that neither scoreX nor scoreX.text is null? Otherwise this looks fine...
Upvotes: 1