I have the following code that works. It successfully displays myName in the NSLog ...
NSURL *apiString = [NSURL URLWithString:@"http://testapi.com/url"];
[XMLConverter convertXMLURL:apiString completion:^(BOOL success, NSDictionary *dictionary, NSError *error)
{
if (success)
{
NSString *myName = dictionary[@"profile"][@"real_name"];
NSLog(@"%@ is my name", myName);
}
}];
I have the following code for the method convertXMLURL which is in XMLConverter.m which I imported. It does a nice job of converting my XML to NSDictionary. That is what I want ...
+ (void)convertXMLURL:(NSURL *)url completion:(OutputBlock)completion
{
///Wrapper for -initWithContentsOfURL: method of NSXMLParser
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:url];
[[XMLConverter new] parser:parser completion:completion];
});
}
The problem I have is *dictionary is a local variable. I need to use it elsewhere in the code. How can I return it?