【问题标题】:UITableViewController access to NSArray that changes from AppDelegateUITableViewController 访问从 AppDelegate 更改的 NSArray
【发布时间】:2012-01-12 03:04:45
【问题描述】:

我的 ApplicationDelegate 中有一个 NSMutableArray,我希望它成为我的 UITableViewController 的数据源。我的问题是如何正确传递对象以跟踪从 AppDelegate 到我的 TableViewController 可能发生的任何更改。

@interface MyTableViewController : UITableViewController {

NSMutableArray *dataSource;
// What property should add for this? (nonatomic, retain) ?

}

那么我怎样才能使这个数组对 TableViewController 可见,而不泄漏内存并且不创建这个数组的第二个实例呢?

- (id) initWithDataSource: (NSMutableArray *) source
{
    dataSouce = source; ???
    dataSource = [source retain];
    // Should I retain? Alloc? 
    // How do I release it?
}

【问题讨论】:

    标签: iphone cocoa-touch uikit uitableview datasource


    【解决方案1】:

    表视图控制器本身就是表视图的数据源。您需要实现the data source methods 以从数组中返回数组和对象的计数。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多