Writing a plist
- by iOS-Newbie
I am trying to test out writing a dictionary to a plist.
The following code does not report any errors, but I cannot find any trace of the file that I supposed wrote.
Here is the code snippet:
NSDictionary *myDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
@"First letter of the alphabet", @"A",
@"Second letter of the alphabet", @"B",
@"Third letter of the alphabet", @"C",
nil
];
I can see the dictionary contents displayed properly with either method calls:
NSLog(@"Here is my partial dictionary %@", myDictionary);
for (NSString *key in myDictionary)
NSLog(@"here it is again %@ %@", key, [myDictionary objectForKey:key]);
The following code displays the "succeeded" message when the program is run repeatedly
if ([myDictionary writeToFile: @"myDictionary" atomically:YES ] == NO)
NSLog(@"write to file failed");
else
NSLog(@"write to file succeeded");
even when changing the atomically: argument to NO to not write a temporary file.
However, when I search my current directory, or even my entire Mac, I cannot find any file called "myDictionary.plist" or any file with the string "myDictionary".
Isn't the path variable "@myDictionary" supposed to represent the file at the current directory, i.e. where the class executable resides?