我想从服务器“更新”本地文件(将其保存到目录中)。我什么都试过了!没有任何效果!这是我最后一次尝试:
NSURL *url = [NSURL URLWithString:@"http://www.doothie.com/QAFrameworks/QAUpdater.php"];
NSData *urlData = [NSData dataWithContentsOfURL:url];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"general.qa"];
NSString *str = [[NSString alloc] initWithData:urlData encoding:NSUTF8StringEncoding];
[str writeToFile:filePath atomically:TRUE encoding:NSUTF8StringEncoding error:NULL];