Is there a better way to handle HTTP error statuses

Is there a better way to handle HTTP error statuses?if ([response respondsToSelector:@selector(stat

Is there a better way to handle HTTP error statuses?

if ([response respondsToSelector:@selector(statusCode)]){    int statusCode = [((NSHTTPURLResponse *)response) statusCode];    if (statusCode >= 400)    {        [connection cancel];  // stop connecting; no more delegate messages        NSDictionary *errorInfo          = [NSDictionary dictionaryWithObject:[NSString stringWithFormat:            NSLocalizedString(@"Server returned status code %d",@""),            statusCode]                                        forKey:NSLocalizedDescriptionKey];        NSError *statusError          = [NSError errorWithDomain:NSHTTPPropertyStatusCodeKey                                code:statusCode                            userInfo:errorInfo];        [self connection:connection didFailWithError:statusError];    }}?