gpt4 book ai didi

ios - 如何在不同的类中使用一个数组?

转载 作者:行者123 更新时间:2023-11-28 19:08:40 26 4
gpt4 key购买 nike

我有一个数组。它填充在一个名为“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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com