How to access variables of other class? This is how i implemented it.
@interface Class1 :NSObject {
NSString *Data; } @property (nonatomic, retain) NSString *Data;
@implementation Class1
@synthesize Data;
someMethod{
self.Data = @"something";
}
and in Class2 :
@implementation Class2
someMethodOfClass2{
Class1 *c=[[Class1 alloc]init];
[c someMethod];
NSString *str=c.Data;
}
I get c.Data as null in Class2. Am i doing anything wrong here?
-----------myClass1--------------
@interface APIManager : NSObject { NSString *Data; }
@property (nonatomic, retain) NSString *Data;
-(void)getData;
@end
@implementation APIManager
@synthesize Data;
-(void)getData{ self.Data=@"response"; }
--------myClass2-------------
@interface Search : NSObject {
}
-(void)searchForItems:(NSString *)query;
@end
@implementation Search
-(void)searchForItems:(NSString *)query { APIManager *apiManager=[[APIManager alloc]init]; [apiManager getData]; NSLog(@"%@",[apiManager Data]); }