我明白我可以例如值寫入一個文件的.plist這樣的Objective-C:寫的.plist中值數組的特定索引
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"stored" ofType:@"plist"];
NSString *comment = @"this is a comment";
[comment writeToFile:filePath atomically:YES];
,但如果我有發言權的數組在我的.plist(gameArray)中,並且我想將comment
變成我陣列的特定索引,即gameArray[4]
;我將如何做到這一點?
讓我澄清
- 我有一個plist中:
stored.plist
- 我的plist裏面有一個數組
gameArray
- 我想更新的plist 內的
gameArray
具體指標這是可能的?
是,但現在你剛剛有一個數據類型'與指數4'comment' array',這不會寫的.plist,我想寫入實際.plist –
已添加示例代碼保存到〜/ Library/Application Support/stored.plist – mrwalker
是的,但是這會向.plist中添加一個數組,它不會更新現有數據:是不是可以更新現有數據? –