i have 2 classes in my app. View1 & View2;
i want to use an object like array, strin, label.text in another class
when i used them the shows null ;
View1.h:
{
NSMutableArray *array;
IBOutlet UILabel *lbl;
NSString *str;
}
@property(nonatomic,retain) NSMutableArray *array;
@property(nonatomic,retain)IBOutlet UILabel *lbl;
@property(nonatomic,retain) NSString *str;
@end;
View1.m
@synthesize array;
@synthesize lbl;
@synthesize str;
array = (1,2,3,..., nil) some dataa
str = @"HAI";
lbl.text = @"Text in label aaaa";
NSLog( @" %@", array );
NSLog( @" %@", lbl.text );
NSLog( @" %@", str );
gives correct out put
but in
View2:
@implementation View2
#import "View1"
.
..
....
View1 *one = [View1 alloc]initwit.....................];
NSLog( @" %@", one.array );
NSLog( @" %@", one.lbl.text );
NSLog( @" %@", one.str );
prints null value
why ? what to do?
thanks in advance..
Very easy. You can allocate this array in your AppDelegate, and then call it from your UIViews. Or you can allocate it in one of your UIViews and set point to this array into AppDelegate.
Example:
Thats it