【发布时间】:2011-05-18 04:22:34
【问题描述】:
我有一个名为PresidentsViewController 的视图控制器类,它在UITableView 中设置数据。该数据采用NSMutableArray 的形式,称为list。我有另一个类PresidentAddController,它应该根据用户输入的有关总统的数据将President 类型的对象添加到此列表中。但是,我无法将对象添加到列表中。我已经确认正在正确收集用户输入的新总统数据,因此它正在添加到另一个导致问题的类中的列表中。我相信将对象添加到列表的正确代码是:
[pvc.list addObject:newPresident];
但是,我不知道如何正确创建引用/实例/? (这就是 pvc 将是什么)到 PresidentAddController 内的 PresidentsViewController 以便我可以正确地将新总统添加到列表中。我没有为此使用 Interface Builder,因为它只是一个 UITableView。
在这种情况下如何将总统添加到列表中?
编辑:这是数组的初始化方式:
@property (nonatomic, retain) NSMutableArray *list;
这是在 PresidentsViewController 中设置 PresidentAddController 的方式:
PresidentAddController *childController = [[PresidentAddController alloc] initWithStyle:UITableViewStyleGrouped];
childController.title = @"Add President";
[self.navigationController pushViewController:childController animated:YES];
[childController release];
【问题讨论】:
-
您可以在初始化可变数组并设置其属性的位置发布代码吗?
-
我刚刚编辑了问题以包含它。
标签: objective-c ios uitableview nsmutablearray