Disclaimer: I'm quite new to Obj-C and iOS (5, ARC enabled).
The following implementation of an NSURLConnectionDelegate method creates EXC_BAD_ACCESS in the NSLog call inside the if:
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
NSLog(@"Response %@", response );
if([response isKindOfClass:[NSHTTPURLResponse class]])
{
NSHTTPURLResponse* httpResponse = (NSHTTPURLResponse*) response;
NSLog(@"HTTP status code %@", [httpResponse statusCode]);
}
}
As far as I managed to find out, the EXC_BAD_ACCESS is caused mostly due to allocation issues, wrong casting, and bad memory management. None of that applies here (I hope).
Thanks in advance, Chris
Solution: Noobie error in formatting the og string. Change the second NSLog to:
NSLog(@"HTTP status code %i", [httpResponse statusCode]);