Reach another class variable or control in iphone
Hi i will try to explain my problem: i'm working with webservices and i need to give variable or label.text to webservice request wich is in another class... I tried in lots ways, but i can't find solution. I know it must be very easy, but i'm new in objective-c so i have problem in primitive situation. Thanks for everyone who will help m开发者_高级运维e :)
Use an instance variable and a property. See here.
In .h:
@interface YourClass : Superclass {
NSString *text;
}
@property (nonatomic, retain) NSString *text;
in .m you have to synthesize it:
@implementation YourClass
@synthesize text;
now you can set this variable like so:
[instanceOfYourClass setText:someText];
get it like so:
someString = [instanceOfYourClass text];
and use it like so (in your implementation):
someString = [self text];
精彩评论