Я пытаюсь получить доступ и изменить массив из другого файла класса. При использовании NSLog я получаю результат (ноль). Ниже мой код:
RootViewController.h
NSMutableArray *listOfItems;
@property (nonatomic, retain) NSMutableArray *listOfItems;
RootViewController.m
@synthesize listOfItems;
listOfItems = [[NSMutableArray alloc] init];
[listOfItems addObject:@"One"];
[listOfItems addObject:@"Two"];
[listOfItems addObject:@"Three"];
SecondViewController.m
RootViewController *test = [[RootViewController alloc] init];
NSLog(@"Results: %@", test.listOfItems);
В консоли я получаю следующие результаты: Results: (null)
Спасибо заранее,
Колтон
P.S. Очевидно, я пропустил кучу кода. Я просто попытался облегчить чтение. Если вам нужно увидеть что-то еще, я был бы более чем рад опубликовать больше. Просто спросите
РЕДАКТИРОВАТЬ # 1:
Я получаю сотни сообщений NSLog, которые выглядят примерно так:
*** __NSAutoreleaseNoPool(): Object 0x4e39020 of class __NSArrayI autoreleased with no pool in place - just leaking
А вот мой код инициализации:
- (id) init {
//NSLog(@"%@", theUserID);
// Set up database connection
NSString *myDB = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"database.db"];
database = [[Sqlite alloc] init];
[database open:myDB];
//Initialize the array.
listOfItems = [[NSMutableArray alloc] init];
// Add to array to display in the tableView
NSArray *listOfItemsTwo = [database executeQuery:@"SELECT * FROM albums"];
for (NSDictionary *rowone in listOfItemsTwo) {
NSString *getName = [rowone valueForKey:@"name"];
if (getName != NULL) {
[listOfItems addObject:getName];
[getName release];
}
}
return self;
}