私はこのコードを持っています:
[NSURLConnection sendAsynchronousRequest:urlRequest queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error)
{
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
if ( error != nil )
{
// Display a message to the screen.
UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"There was a server error getting your business plan. We use a remote server to backup your work."
message:@"Please make sure your phone is connected to the Internet. If the problem persists, please let us know about this."
delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[message show];
ただし、NSUrlConnection がサーバーから返されたときに実行されます。まれにクラッシュが発生します。出来ますか?無害なコードのように思えます。
ありがとう!