Here is my code:
MainDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
FetchManager *fetchManager = [FetchManager sharedInstance];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH,0), ^{
[fetchManager fetchData];
});
}
FetchData.m (this is a singleton class)
- (id)getInstance { ... }
- (void)fetchData
{
NSURL *url = [NSURL URLWithString:@"http://www.data.xml"];
NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30];
if (connectionInProgress) {
[connectionInProgress cancel];
[connectionInProgress release];
}
[xmlData release];
xmlData = [[NSMutableData alloc] init];
connectionInProgress = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES];
}
Problem: None of the NSXMLParserDelegate protocol methods are running. I do not know why. If I remove "dispatch_async" in the didFinishLaunchingWithOptions method, then everything will work as expected - the NSXMLParserDelegate protocol methods are running.
Does anyone see a problem?
source
share