2016-01-05 101 views

回答

0

您應該使用一個NSMutableArray

而且用這種方法:

[yourArray replaceObjectAtIndex:INDEX withObject:OBJECT]. 
+0

嗨,我有修改的程序類似的NSMutableArray *測試= @ @ 「ABC」,@ 「REC」,@「myPM 「]; NSLog(@「%@」,[test objectAtIndex:0]); [test replaceObjectAtIndex:0 withObject:@「001」]; NSLog(@「%@」,[test objectAtIndex:0]);但仍然在程序中出現錯誤,如逗號'@',逗號表達式的左側操作數沒有任何作用 – user3041176

+0

試試這個: NSMutableArray * test = [NSMutableArray arrayWithObjects:@「abc」,@「rec」,@「myPM」 ,無]; NSLog(@「%@」,[test objectAtIndex:0]); [test replaceObjectAtIndex:0 withObject:@「001」]; NSLog(@「%@」,[test objectAtIndex:0]); – Pipiks