file read and write

    //document content   

    NSString *content = @"aShen. All rights rese";

    //file path

    NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"jsdfhj.text"];

//     atomically   :YES first store the content of the written file in a temporary file, if successful, it will overwrite the source file, NO directly delete the content of the file and write the new content directly

    BOOL isWrit = [content writeToFile:path atomically:YES encoding:NSUTF8StringEncoding error:nil];

    if (isWrit) {

        NSLog( @"Write successful");

    }else{

        NSLog( @"Write failed");

    }

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324769089&siteId=291194637