我有一個名爲PresidentsViewController
的視圖控制器類,它在UITableView
中設置數據。該數據的格式爲NSMutableArray
,稱爲list
。我有另一個課程,PresidentAddController
,應該根據用戶輸入的有關總統的數據來處理將類型爲President
的對象添加到此列表中。但是,我無法將對象添加到列表中。我已經確認用戶爲新總統輸入的數據正在被正確收集,因此它正在添加到導致問題的另一個類中的列表中。我認爲正確的代碼將一個對象添加到列表是:將對象添加到其他類的NSMutableArray中
[pvc.list addObject:newPresident];
不過,我不知道如何正確地創建參考/實例/? (這是pvc會是什麼)PresidentialViewController內的PresidentAddController,以便我可以正確地添加一個新的總統到列表中。我沒有爲此使用Interface Builder,因爲它只是一個UITableView。
在這種情況下,如何將總統添加到列表中?
編輯:這裏是如何的數組初始化:
@property (nonatomic, retain) NSMutableArray *list;
這裏是PresidentAddController是如何被設置在PresidentsViewController:
PresidentAddController *childController = [[PresidentAddController alloc] initWithStyle:UITableViewStyleGrouped];
childController.title = @"Add President";
[self.navigationController pushViewController:childController animated:YES];
[childController release];
你可以發佈你的代碼初始化你的可變數組並設置其屬性? – Krishnan 2011-05-18 04:37:58
我剛剛編輯了包含該問題的問題。 – epaps 2011-05-18 04:59:51