2
<plist version="1.0">
<dict>
<key>InfoValue</key>
<string>false</string>
<key>AudioValue</key>
<string>true</string>
<key>VideoValue</key>
<string>true</string>
<key>DescValue</key>
<string>true</string>
<key>LinkValue</key>
<string>true</string>
</dict>
</plist>
這是plist文件,我想更改InfoValue的dyanamically。在我的代碼我米使用像如何在設置動態值後將數據保存到plist中?
settingsPath=[[NSBundle mainBundle] pathForResource:@"SettingsValue" ofType:@"plist"];
settingsItem = [[NSMutableDictionary alloc] initWithContentsOfFile:settingsPath];
[settingsItem setObject:@"false" forKey:@"InfoValue"];
並在此之後
[settingsItem writeToFile:settingsPath atomically:YES];
,但它不是將數據保存到plist文件。而不是我得到以下錯誤:
-[NSConcreteValue getFileSystemRepresentation:maxLength:]: unrecognized selector sent to instance 0x8fad490
2013-02-27 10:26:44.479 vCamView[1577:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '-[NSConcreteValue getFileSystemRepresentation:maxLength:]: unrecognized selector sent to instance 0x8fad490'
*** First throw call stack:
(0x33dc012 0x2944e7e 0x34674bd 0x33cbbbc 0x33cb94e 0x2354915 0x23548b9 0x2354872
0x235468f 0x1e207 0x2958705 0x188f920 0x188f8b8 0x1950671 0x1950bcf 0x1a90747
0x2342e83 0x339b376 0x339ae06 0x3382a82 0x3381f44 0x3381e1b 0x376f7e3 0x376f668
0x188c65c 0x27e2 0x2715)
檢查此鏈接http://stackoverflow.com/questions/4075056/what-are-the-options-for-saving-data-in-ios – 2013-02-27 05:22:01
的應用程序的包是隻讀的。你不能將plist數據寫回到包中。 – rmaddy 2013-02-27 05:23:54