0

I am new to iOS. I have a plist that contains:

<plist version="1.0">
<dict>
    <key>MsgTest</key>
    <array>
        <dict>
            <key>Order</key>
            <string>Value</string>
        </dict>
    </array>
</dict>
</plist>

I do want to change the

NSString @"Value" with : NSString *result=@"Alphabetic". I did the following:

     plistOrder = [[NSBundle mainBundle] pathForResource:@"PList" ofType:@"plist"];
        orderDictionary = [[NSDictionary dictionaryWithContentsOfFile:plistOrder] mutableCopy];
        SettingArray = [[orderDictionary objectForKey:@"MsgTest"]mutableCopy];

    [SettingMutableDictionary setValue:result forKey:@"Order"];
            [SettingMutableArray replaceObjectAtIndex:0 withObject:SettingDictionary];

             [orderDictionary setValue:SettingArray forKey:@"MsgTest"];

            BOOL success= [orderDictionary writeToFile:plistOrder atomically:YES];
            if (success){
                NSLog(@"!!!!!!!!!!!!!success");
            }

but the bool success is NO. Why? What am I doing wrong?

UPDATE

The plist in which I want to change data is in Resource folder.

just ME
  • 1,817
  • 6
  • 32
  • 53
  • 5
    You are trying to write a file into application bundle - which is read-only. You can save it do Documents folder. Take a look at: http://stackoverflow.com/a/5608107/653513 – Rok Jarc Nov 14 '13 at 21:02
  • 1
    The dictionary you show does not have a `Settings` property (besides the problem already mentioned). – Gerd K Nov 15 '13 at 02:54

0 Answers0