ios - 返回自定义对象而不是字符串的数组枚举

标签 ios objective-c nsarray enumerator

我在从数组而不是字符串中检索 NSString 时遇到问题,我取回了字符串所在的对象。这是我的结构。

NSMuteableArray > ArrayOfObjects > NSString(这个字符串在对象数组中的每个对象中)。

我正在尝试将字符串分配给 TableView 中的单元格,但现在我只想注销正确的数据。这是我正在尝试的代码,它再次起作用,但我取回了父对象而不是字符串。

for (NSString *amountOwed in [[[dataSingelton mutableDataArray] objectAtIndex:indexPath.row]personsBillsArray])
{
    NSLog(@"the value owed is %@", amountOwed);
}

personsBillsArray 中的每个对象都有一个属性 amountOwed

最佳答案

你很接近:

NSArray *array = [[[dataSingelton mutableDataArray] objectAtIndex:indexPath.row] personsBillsArray];
for (id obj in array)
{
    NSString *amountOwed = [obj amountOwed];
    NSLog(@"the value owed is %@", amountOwed);
}

关于ios - 返回自定义对象而不是字符串的数组枚举,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20816324/

相关文章:

ios - iOS 中的设计模式作为装饰器模式

swift - 如何在 Swift 3 中按条件对数组进行排序

ios - 在两个 UITabBarController 之间切换?

ios - 另一个 UIButton 背景颜色问题

ios - 当传输编码的响应 header 值被分块时,NSURLCache 不起作用

ios - json 文件中的 NSString 无法识别撇号

ios - 在 Swift 中设置带边距的 UITableViewCell 框架

ios - iOS:UIView子类init会先调用[super init],然后再调用父类中的方法,为什么会调用[subclass initWithFrame:xx]?

ios - 搜索栏 - 过滤 Collection View 数据源的搜索词数组

ios - 无法从公共(public)可变数组 (Objective-C) 中删除对象