【发布时间】:2013-05-31 19:36:23
【问题描述】:
我有一个 NSArray,它通过 JSON 获取 WS 一些日期值。 这就是我的 NSLOG 返回的内容: "2013-05-31T17:00:00Z", "2013-05-31T17:30:00Z", "2013-05-31T18:00:00Z", "2013-05-31T20:00:00Z", ...
我需要一个只返回小时和分钟的新 NSArray,如下所示: "17:00", "17:30", "18:00", "20:00", ...
我正在做类似的事情:
for (int a =0; a<array2.count; a++)
{
NSString *myString = [array2 objectAtIndex:a];
NSString *horaDeInicio = [myString substringWithRange:NSMakeRange(11, 5)];
[horariosProgramas addObject:horaDeInicio];
}
回复正是我所需要的,但回复只有一大串。所以我的数组只有一个对象。我需要在对象中分离这个大字符串。我怎样才能做到这一点?? 谢谢!
【问题讨论】:
-
你能告诉我们你是如何创建然后显示或使用
horariosProgramas从而得出结论它变成了一个大字符串吗? -
in viewDidLoad: horariosProgramas = [[NSMutableArray alloc] init];当我在 tableview detailEmissoraViewController.horariosProgramas = [horariosProgramas objectAtIndex:[sender tag]] 中连续选择一个按钮时;而detailEmissoraViewController,horariosPrograma是一个属性。在 cellForRowAtIndexPath 我尝试使用 NSString *subCellValue = [horariosProgramas objectAtIndex:indexPath.row]; cell.detailTextLabel.text = subCellValue;但它崩溃了 -[__NSCFString objectAtIndex:]: unrecognized selector sent to instance
-
但是如果你已经完成了
.horariosProgramas = [horariosProgramas objectAtIndex:[sender tag]];,那么本地属性肯定是一个字符串,而不是一个数组,当你下次尝试subCellValue = [horariosProgramas objectAtIndex:indexPath.row];时会导致问题? -
哼,是的,你是对的!那么我该如何解决这个问题??
标签: ios json nsstring nsmutablearray substring