开发者

Reach another class variable or control in iphone

开发者 https://www.devze.com 2023-02-02 09:27 出处:网络
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 s

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];
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号