Passing a NSArray between classes
- by Althane
So, my second question based off of this application I'm teaching myself Objective C with. I have a Data Source class, which for now looks mostly like:
- (id) init
{
if (self = [super init]){
listNames = [[NSArray alloc] initWithObjects: @"Grocery", @"Wedding", @"History class",@"CS Class",@"Robotics",@"Nuclear Sciences",
@"Video",@"Library",@"Funeral", nil];
NSLog(@"%@",listNames);
}
return self;
}
The .h looks as follows:
@interface MainViewDataSource : NSObject {
NSArray *listNames;
}
@property (nonatomic, retain) NSArray *listNames;
-(NSArray *)getListNames;
So that's where I make it. Now the problem is that when I try to get the array listNames, it returns nothing.
The following piece:
NSArray* data = [listData listNames];
Is supposed to put the information in listNames in data, but... isn't. Since I'm rather used to JAva, I'm betting this is an Objective C quirk that I don't know how to fix. Which is why I'd be here asking for help. What's the proper way to pass around NSArrays like this?