0
我需要我的用戶名和密碼存儲到一個XML文件中的格式如何編寫XML文件中的iPhone
<user>abcde</user>
<pass>123355</pass>
我怎麼能寫這個文件,這樣就可以輕鬆地閱讀它的文檔目錄?
我需要我的用戶名和密碼存儲到一個XML文件中的格式如何編寫XML文件中的iPhone
<user>abcde</user>
<pass>123355</pass>
我怎麼能寫這個文件,這樣就可以輕鬆地閱讀它的文檔目錄?
正如@Mike ..建議的那樣,您應該使用鑰匙串來存儲密碼..谷歌它..有在線教程。
至於xml存儲。 下面是代碼
NSData *serializedData;
NSString *error;
serializedData = [NSPropertyListSerialization dataFromPropertyList:YourArray(You can use dictionaries.strings..and others too)
format:NSPropertyListXMLFormat_v1_0 errorDescription:&error];
if (serializedData) {
// Serialization was successful, write the data to the file system // Get an array of paths.
NSArray *documentDirectoryPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docDir = [NSString stringWithFormat:@」%@/serialized.xml」,
[documentDirectoryPath objectAtIndex:0]];
[serializedData writeToFile:docDir atomically:YES];
}
else {
// An error has occurred, log it
NSLog(@」Error: %@」,error); }
}
如果要存儲的「祕密」一樣的密碼,你應該考慮使用的鑰匙串。 – 2012-02-03 13:07:05
我該怎麼做 – Ali 2012-02-03 13:08:05