I am trying to pass a NSMutableArray between UIViewController and a class.
I have a Class:
@interface uClass : NSObject<>{
NSMutableArray *arr;
}
@property (nonatomic,retain) NSMutableArray *arr;
@synthesize arr;
-(void)getData{
arr = [[NSMutableArray alloc]initWithCapacity:10];
[arr addObject:@"1.3"];
[arr addObject:@"2.9"];
}
in the UIViewCOntroller, In MapScreen.h,
#include "uClass.h"
@interface MapScreen : UIViewController<>{
NSMutableArray *cor;
}
In MapScreen.m,
-(void)setPosition{
uClass *u = [[uClass alloc]init];
cor =[[NSMutableArray alloc]initWithCapacity:10];
cor = u.arr;
}
When i try to obtain the first object [cor objectAtIndex:0], it is null. Could someone please tell me whats happening??
Ok an update on what exactly i am doing,
The uClass contains a thread which runs continously in the background, it started by the click of a button. During this process getData is called and arr NSMutableArray is populated.
Now when i move to MapScreen UIViewController and click on a button, it should get the NSMutableArray arr from uClass. But when i do that it gives a null. I hope this is more clearer.