Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>.plist that you created with Xcode interface is readable but not writeable. If you want to make changes to the file in the project Bundle primarily in one of the folders within the Documents or Library to copy and then there always have to work on the copy or create the .plist with code.</p> <p>Creating:</p> <pre><code>NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSString* plistPath = [documentsPath stringByAppendingPathComponent:@"test.plist"]; NSArray* fruits= [NSArray arrayWithObjects:@"apple", @"orange", @"cherry", nil]; NSArray* vegetables= [NSArray arrayWithObjects:@"cabbage", @"pumpkin", @"leek", nil]; NSDictionary* dictionary= [NSDictionary dictionaryWithObjectsAndKeys:fruits, @"fruits", vegetables, @"vegetables", nil]; [dictionary writeToFile:plistPath atomically:YES]; </code></pre> <p>Reading and Writing:</p> <pre><code>NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSString* plistPath = [documentsPath stringByAppendingPathComponent:@"test.plist"]; NSDictionary* dictionary= [[NSDictionary alloc] plistPath ]; NSMutableArray* fruits= [dictionary objectForKey:@"fruits"]; NSMutableArray* vegetables= [dictionary objectForKey:@"vegetables"]; NSLog(@"First Fruit: %@",[fruits objectAtIndex:0]); NSLog(@"First Vegetable: %@",[vegetables objectAtIndex:0]); [fruits replaceObjectAtIndex:0 withObject:@"banana"]; [dictionary writeToFile:plistYolu atomically:YES]; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload