2015-11-05 64 views

回答

0

首先,當您檢索.plist文件時,請將其存儲爲NSMutableDictionary

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"your plist name" ofType:@"plist"]; 
NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithContentsOfFile:filePath]; 
NSMutableArray *filmsPlaying = [[NSMutableArray alloc] iniWithArray:[dict objectForKey:@"FilmsPlaying"]]; 
NSMutableDictionary *filmToEdit = [filmsPlaying objectAtIndex:1];// IRL run a loop to get your desired film 
NSString *newSeats = @"1-2-9"; 
[filmToEdit setObject:newSeats forKey:@"ZFILMSEAT"]; 
[filmsPlaying replaceObjectAtIndex:1 withObject:filmsToEdit]; 
[dict setObject:filmsPlaying forKey:@"FilmsPlaying"]; 

在這裏你有你想編輯的電影。將版本編入該字典後,需要將其寫回到應用程序的文檔目錄中。 (注意:您不能將其保存回您的主包,但您可以將其寫入文檔)。

NSString *pathForPlist = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; 
pathForPlist = [savingPath stringByAppendingPathComponent:@"your plist name.plist"]; 
[dict writeToFile:savingPath automically:YES]; 

要在主束編輯它無需任何編程,你可以簡單地在任何文本編輯器或自身的xcode打開它,讓你的版本。沒有什麼技術。

相關問題