我已经尝试了一周让 writeToUrl 工作,但没有......什么都没有。我只是想从 iPhone 应用程序更新我服务器上的文件。这是代码:
NSURL *url = [NSURL URLWithString:@"http://user:pw@192.168.120.167/test.txt"];
NSString *teststring = @"it works";
if ([teststring writeToURL:url atomically:YES encoding:NSASCIIStringEncoding error:nil]) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Status" message: @"Yessss" delegate: self cancelButtonTitle: @"Close" otherButtonTitles: nil];
[alert show];
[alert release];
}
else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Status" message: @"Noooooo" delegate: self cancelButtonTitle: @"Close" otherButtonTitles: nil];
[alert show];
[alert release];
}