2

writeToUrl を機能させるために 1 週​​間試してみましたが、いいえ... 何もありません。サーバー上のファイルを 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];

}
4

2 に答える 2