2011-12-20 45 views
0
NSDictionary *item = [NSDictionary dictionaryWithObjectsAndKeys: 
           eyeNameHolder,@"eye", 
           lipsNameHolder,@"lips",nil]; 

NSMutableArray *arrayItems = [NSMutableArray arrayWithObject:item]; 
[arrayItems insertObject:item atIndex:dynamical variable]; 
[arrayItems writeToFile:finalPath atomically:YES]; 

如何通過點擊不同的按鈕從0到10發送不同的值從0到10動態替換atIndex的值?動態替換atIndex的值嗎?

回答

3

NSMutableArrayreplaceObjectsAtIndex:withObject:,你可以試試:

[arrayItems replaceObjectsAtIndex:atIndex withObject:/*0-10*/]; 
+0

對不起,我不明白這項工作是如何的?你想解釋更多嗎? ?將這個引起我的物品1,ITEM2存儲不同指數在相同的值我是說我的plist假設是這樣的: \t 物品1 \t \t \t \t \t eye_blue \t \t 雙脣 \t \t lips_blue \t \t ITEM2 \t \t \t \t \t eye_green \t \t 嘴脣 \t \t lips_green \t \t 項 \t Albert 2011-12-20 04:44:34

+0

'replaceObjectsAtIndexes:withObjects:'被簡單地描述爲**替換*對象*在有* anObject *指數**見http://developer.apple.com/library。 /ios/documentation/Cocoa/Reference/Foundation/Classes/NSMutableArray_Class/Reference/Reference.html#//apple_ref/occ/instm/NSMutableArray/replaceObjectAtIndex:withObject: – WrightsCS 2011-12-20 04:48:09

0

我不喜歡的東西下面,它工作正常。

AppDelegate* ref = (AppDelegate*) [[UIApplication sharedApplication] delegate]; 

NSMutableDictionary *item = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
           eyeNameHolder,@"eye", 
           lipsNameHolder,@"lips",nil]; 

[arrayItems replaceObjectAtIndex:ref.IndexerHolder withObject:item]; 
     [arrayItems writeToFile:finalPath atomically:YES];