I have a weird error that I cannot seem to find any documentation or posts for. When I try to connect to my web service (changed URL for privacy) using the standard textbook method, I receive EXC_BAD_INSTRUCTION or EXC_BAD_ACCESS on [NSURLConnection initWithRequest].
The weirdest thing is that on occasion I can step over the offending line without any exception, but 9 times out of 10 it causes this error. Any suggestions?
- (void)viewDidLoad {
NSURL *url = [NSURL URLWithString:@"http://heres/where/my/webservice/url/is/"];
NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:30.0];
// cancel any old connection
if(connection) {
[connection cancel];
[connection release];
}
// create new connection and begin loading data
connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
if(connection) {
// if the connection was created correctly, release old data (if any), and alloc new
[data release];
data = [[NSMutableData data] retain];
}
[url release];
[request release];
}
Any help or suggestions or RTFMs will be much appreciated!