下面的代码NSMutableArray
从一个对象中获取值,从一个对象中获取值,然后将它们添加到另一个对象中NSMutableArray
以供使用。我需要做的是为每个项目添加一个新行,NSMutableArray *options
但它崩溃说:
[__NSSingleObjectArrayI 长度]:发送到实例的无法识别的选择器
如果我注释掉 中的代码for (int i = 0; i < options.count; i++)
并留下NSLog(@"FIELD)
它,它会显示正确的值。有任何想法吗?
LFFormSectionLabel *sectionLabel = [LFFormSectionLabel new];
[sectionLabel addValue:header forSEL:@selector(setText:)];
[vc addSection:sectionLabel];
NSMutableArray *options = [[NSMutableArray alloc] init];
for (NSDictionary *item in self.surveydata) {
NSString *addressfield = [item objectForKey:@"address_option"];
[options addObject:addressfield];
}
for (int i = 0; i < options.count; i++) {
NSString *field = [options objectAtIndex:i];
LFFormRowTextField *rowTextField = [LFFormRowTextField new];
rowTextField.key = @"name";
[rowTextField addValue:field forSEL:@selector(setPlaceholder:)];
[sectionLabel addRow:rowTextField];
NSLog(@"FIELD: %@", field);
}