I have created the following method in cocoa:
-(NSArray *)latestData
{
NSURL *requestingURL = [NSURL URLWithString:@"someRestfulURL"];
NSMutableURLRequest *theRequest =[NSMutableURLRequest requestWithURL:requestingURL];
[theRequest setHTTPMethod:@"GET"];
NSURLConnection *theConnection = [NSURLConnection connectionWithRequest:theRequest delegate:self];
if(theConnection)
{
webData = [[NSMutableData data]retain];
}
else
{
NSLog(@"the connection is NULL");
}
return someArray;
}
The RESTful webservice I am calling returns XML that I parse using NSXMLParser.
How can I return an array when calling latestData
if I have to wait for the delegate methods of NSURLConnection and NSXMLParser to finish before I can fill the array with the appropriate data?