我有一个数组。它填充在一个名为“SampleDataDAO”的类中。
我需要什么:
在名为“MainMenu”的第二个类中,我需要保留此代码:
- (void)viewDidLoad
{
[super viewDidLoad];
daoDS = [[SampleDataDAO alloc] init];
self.ds = daoDS.PopulateDataSource;
}
在名为“HView”的第三个类中,我需要使用数组“ds”(NSMutableArray)。 但是我需要使用它已经从二等舱填充,以返回元素的数量:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return ds.count;
}
感谢您的帮助!
最佳答案
为什么你不应该有一个单例类,并将该数组作为该单例类的成员。
找到有关单例的更多信息 here
关于ios - 如何在不同的类中使用一个数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17856788/