1

I have an app that has a label in an xib, which contains text. I would like to assign the text to an NSString for use in other areas of the View. My attempt to accomplish this is:

  • In the xib, select the label, show the Identity Inspector, and under Document, fill in the Label field with the desired label name - example: mylabelname
  • In the .m file, of the same name as the xib, inside a method, assign the value of the label to the variable, example: mytextfield

    NSString *mytextfield =[mylabelname.text];

I get an error on the above - Use of undeclared identified 'mylabelname'.

From my research, I think I want to do something like this in my label:

[label mytextfield: mylabelname.text];

Or something similar, but I am not sure how, or where. Can anyone provide me some pointers or guidance on this? I bet this is simple, but I have not been able to figure it out.

Thanks! Rob

4

2 回答 2

2

NSString *myString = myLabel.text;

Your problem is enclosing this in []'s

于 2013-03-31T03:42:47.140 回答
2

Any one will work

NSString *mytextfield =[mylabelname text];

or,

NSString *mytextfield =mylabelname.text;
于 2013-03-31T03:51:12.050 回答