NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"demo" ofType:@"plist"]; NSMutableDictionary *plistData = [[NSMutableDictionary alloc] initWithContentsOfFile:plistPath];
將 .plist 載入之後就可以對其進行操作,相關程式碼如下。 //取得Root下的score值,這裡是50
[plistData objectForKey:@"score"];
//設定Root下的score值為10
[plistData setValue:@"10" forKey:@"score"];
//取得D1下的score值,這裡是100
[[plistData objectForKey:@"D1"] objectForKey:@"score"];
//設定D2下的score值為200
[[plistData objectForKey:@"D2"] setValue:@"200" forKey:@"score"];
沒有留言:
張貼留言