У меня есть эта строка:
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Secciones</key>
<array>
<dict>
<key>Uid</key>
<integer>1</integer>
<key>DateInsert</key>
<date>3911-04-15T09:20:40Z</date>
<key>DateModify</key>
<date>3911-04-15T09:20:40Z</date>
<key>Name</key>
<string>Seccion 1</string>
<key>Description</key>
<string>Esta es la sección 1.</string>
</dict>
<dict>
<key>Uid</key>
<integer>2</integer>
<key>DateInsert</key>
<date>3911-04-15T09:20:40Z</date>
<key>DateModify</key>
<date>3911-04-15T09:20:40Z</date>
<key>Name</key>
<string>Seccion 2</string>
<key>Description</key>
<string>Esta es la sección 2.</string>
</dict>
<dict>
<key>Uid</key>
<integer>3</integer>
<key>DateInsert</key>
<date>3911-04-15T09:20:40Z</date>
<key>DateModify</key>
<date>3911-04-15T09:20:40Z</date>
<key>Name</key>
<string>Seccion 3</string>
<key>Description</key>
<string>Esta es la sección 3.</string>
</dict>
</array>
</dict>
</plist>
Я хочу создать файл plist с этим содержимым. Я пытался с этим:
NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES) objectAtIndex:0];
NSString *fileName = [documentsDirectory stringByAppendingPathComponent: @"sec.plist"];
NSLog(@"%@",documentsDirectory);
NSLog(@"%@",fileName);
//n is my string
[n writeToFile:fileName
atomically:NO
encoding:NSStringEncodingConversionAllowLossy
error:nil];
мое консольное шоу:
2011-09-08 18:26:59.999 Catalogo-V1[1071:207] /Users/.../Library/Application Support/iPhone Simulator/4.3/Applications/6D96FC16-D6CB-4A03-A0F5-38A0C0C473C7/Documents
2011-09-08 18:27:00.000 Catalogo-V1[1071:207] /Users/.../Library/Application Support/iPhone Simulator/4.3/Applications/6D96FC16-D6CB-4A03-A0F5-38A0C0C473C7/Documents/sec.plist
Но не создавайте никаких файлов.