Advertisement
thieumao

Check error 404

Sep 1st, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. NSURLRequest *request;
  2. NSURLResponse *response = nil;
  3. NSError **error=nil;
  4. NSData *data=[[NSData alloc] initWithData:[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:error]];
  5. NSString* retVal = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
  6. // you can use retVal , ignore if you don't need.
  7. NSInteger httpStatus = [((NSHTTPURLResponse *)response) statusCode];
  8. NSLog(@"responsecode:%d", httpStatus);
  9. // there will be various HTTP response code (status)
  10. // you might concern with 404
  11. if(httpStatus == 404)
  12. {
  13.    // do your job
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement