I'm really struggling with an app I'm writing at the moment.
I've got some intense string manipulation, which I'm performing inside a dispatch_async block.
At the end of the block I've got a dispatch_async(dispatch_get_main_queue()) block, which calls a custom function: getPrices();
Inside getPrices() I use an NSURLConnection. The delegate methods are not being called, my connection is made, but I don't get a fail, success, authentication challenge, anything at all.
The code looks like this:
Code:
- (void)performSearch {
// set some defaults and work out if it is a valid search, setting bSearchOk
if (bSearchOk) {
// update some interface elements
self.msgBox.text = @"Translating...";
self.plateInput.enabled = NO;
self.searchProgress.hidden = NO;
dispatch_async( dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// create a new search
Search *oPlateSearch = [[Search alloc] initWithTerm:thisTerm];
// ...
// perform search... this calls a variety of slow and intensive functions
// ...
self.aFinalPlates = [oPlateSearch.aValidated copy];
self.aCurrentPlates = [oPlateSearch.aFinals copy];
dispatch_async( dispatch_get_main_queue(), ^{
[oPlateSearch release];
// make ajax call to check if plates can be bought
[self getPrices];
});
});
} else {
// hide results
self.searchResults.hidden = YES;
}
}
And this is getPrices()
Code:
/* call to get plate availability and prices */
-(void) getPrices {
// set return message
self.msgBox.text = @"Getting prices and availability";
// ...
// then I build my strRequest var, which is a valid working URL
// ...
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:strRequest]];
NSURLConnection *loginConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:NO];
[loginConnection scheduleInRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
[loginConnection start];
NSLog('This will get logged');
if(loginConnection) {
NSLog('This will also get logged');
self.jsonSearchResponse = [[[NSMutableData data] retain] autorelease];
NSLog('And this will get logged, so it's not throwing errors');
} else {
NSLog(@"Failed to get search results");
}
}
Any ideas what I'm doing wrong?