我想將字符串拆分成部分並插入到表中我應該怎麼做?拆分nsstring並將其放入tableview
我得到用於陣列的分割的誤差,其: - [__ NSArrayI componentsSeparatedByString:]:無法識別的選擇發送到實例0x7a421e0
NSArray *BusRoute = alightDesc;
int i;
int count = [BusRoute count];
for (i = 0; i < count; i++)
{
NSDictionary *dic = [BusRoute objectAtIndex: i];
NSDictionary *STEPS = [dic valueForKey:@"STEPS"];
NSString *AlightDesc = [STEPS valueForKey:@"AlightDesc"];
NSLog(@"AlightDesc = %@", AlightDesc);
NSArray *aDescArray = [AlightDesc componentsSeparatedByString:@","];
NSLog(@"aDescArray = %@", aDescArray);
}
這是我拆分,我得到它從字符串NSLog
AlightDesc = (
"Block1",
"Block2",
"Block3"
)
請幫助我卡住了謝謝。
您的'AlightDesc'包含數組,它是一個數組。不是字符串。那就是爲什麼它會拋出異常 – janusbalatbat 2012-07-23 08:47:41
我該怎麼辦?任何建議 – sihao 2012-07-23 09:31:18
閱讀你的問題,你不需要分割你的數據,你可以在你的表格中顯示出來'[AlightDesc objectAtIndex:indexPath.row]'而且,'NSArray的* AlightDesc =〔工序valueForKey:@「AlightDesc」] ;'而不是'NSString' – janusbalatbat 2012-07-23 09:32:46