2

XML是否可以在 iPad 上创建文件Objective-C

让我解释一下,我连接到一个返回XML文件的数据库,我必须将此内容写入XML在 iPad 上创建的文件中。

编辑 :

这是我的创建代码.txt file,但我在文档中找不到它。

    NSError *error;
    //get the documents directory:
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    //NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
    //make a file name to write the data to using the documents directory:
    NSString *fileName = [NSString stringWithFormat:@"%@/textFile.txt", documentsDirectory];
    //create content - four lines of text
    NSString *content = serverOutput;
    //save content to the documents directory
    /*[content writeToFile:fileName atomically:NO];*/
    [content writeToFile:fileName atomically:YES encoding:NSUTF8StringEncoding error:&error];

难道我做错了什么 ?

4

0 回答 0