私はしばらくこのことに悩まされており、これを回避していないようです。NSCocoaErrorDomain Code = 256
私はURLから文字列としてURLの内容を読み取るしようとしていますが、私は奇妙な
Error -> Error Domain=NSCocoaErrorDomain Code=256 "The operation couldn’t be completed. (Cocoa error 256.)"
私のコードを取得:
fetchedString = [[NSString alloc] initWithContentsOfURL:[NSURL URLWithString:@"www.example.com/iphone"] encoding:NSUTF8StringEncoding error:&error];
NSLog(@"%@",fetchedString);
// if there is something wrong with the URL
if (error) {
NSLog(@"Error -> %@", error);
return ;
}
私が間違っているのは何を? NSDataとして取得しようとしましたが、nullが返されます。
URL部分に「http://」を追加してみてください。 – Eimantas
が機能しました。ありがとう:) – Neelesh