配列があり、配列を反復処理するときに、アイテムも置き換えたいと思いました。これは不可能であり、そうするとクラッシュが発生しますか? コードは次のとおりです。
for (int i = 0; i < [highlightItemsArray count]; i++){
//replace the from array with the new one
NSMutableDictionary *tempDictionary = [NSMutableDictionary dictionaryWithDictionary:highlightItem];
[tempDictionary setObject:[newHighlightItem objectForKey:@"from"] forKey:@"from"];
[highlightItemsArray replaceObjectAtIndex:i withObject:tempDictionary];
[indexes addIndex:i];
}
これがObjective-Cで合法かどうか知りたいだけですか?そうでない場合、そうする代わりに何ができますか?