ios - [__NSCFString countByEnumeratingWithState :objects:count:]: unrecognized selector sent to instance 0x16e09f70'

标签 ios objective-c nsarray

由于未捕获的异常“NSInvalidArgumentException”而导致错误 Terminating app,原因:“-[__NSCFString countByEnumeratingWithState:objects:count:]: 无法识别的选择器发送到实例 0x16e09f70”

if (finalArray.count != 0)
    {
        NSMutableDictionary *fetchDict = [[NSMutableDictionary alloc]initWithDictionary:[finalArray objectAtIndex:indexPath.row]];
        NSMutableArray *valueArr = [[NSMutableArray alloc]initWithArray:[fetchDict allValues].mutableCopy];


        for (NSMutableArray *one in valueArr) {
            for (NSMutableArray *two in one) // Program Stops on This Line
            {
                cell.textLabel.text = [NSString stringWithFormat:@"%@",[two valueForKey:@"Note"]];
            }
        }

    }
}

最佳答案

试试这个

if (finalArray.count != 0)
{
    NSMutableDictionary *fetchDict = [[NSMutableDictionary alloc]initWithDictionary:[finalArray objectAtIndex:indexPath.row]];
    NSMutableArray *valueArr = [[NSMutableArray alloc]initWithArray:[fetchDict allValues].mutableCopy];


    for (NSMutableArray *one in valueArr) {
        if ([one isKindOfClass:[NSMutableArray class]]) { //Check if array here
            for (NSMutableArray *two in one) 
            {
                cell.textLabel.text = [NSString stringWithFormat:@"%@",[two valueForKey:@"Note"]];
            }
        }else {
            NSLog(@"Program stops because this one: %@", one);
        }
    }

}

关于ios - [__NSCFString countByEnumeratingWithState :objects:count:]: unrecognized selector sent to instance 0x16e09f70',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36328756/

相关文章:

ios - 节拍器 ios 快速节拍视觉滞后

ios - UINavigationBar 外观背景图像在 iOS 7.1 中重复和模糊

ios - 无法向 iOS 查询当前用户语言

ios - 将整数添加到索引处的数组对象时出错( objective-c )

ios - 快速检测音量变化

ios - 如何在 Objective-C 中正确同步对实例变量的访问

ios - AVAudioPlayer 被释放,而键值观察者仍然在其中注册

c - 由电影支持的 QTMovie 最初可以工作,但不能以其他方法工作

xcode - 将 NSArray 转换为 NSString 会崩溃?

objective-c - 用 NSArray 替换 NSMutableArray 的内容