return string from function objective c

cagawcmnuw

New Member
I have this function that will get xml through a request operation:\[code\]-(id)xmlRequest:(NSString *)xmlurl{ AFKissXMLRequestOperation *operation = [AFKissXMLRequestOperation XMLDocumentRequestOperationWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:xmlurl]] success:^(NSURLRequest *request, NSHTTPURLResponse *response, DDXMLDocument *XMLDocument) { NSLog(@"XMLDocument: %@", XMLDocument); } failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, DDXMLDocument *XMLDocument) { NSLog(@"Failure!"); }]; [operation start]; return operation;}\[/code\]This is my code that calls this function:\[code\]Request *http=[[Request alloc] init];NSString *data=http://stackoverflow.com/questions/11420358/[http xmlRequest:@"http://legalindexes.indoff.com/sitemap.xml"];NSError *error;DDXMLDocument *ddDoc=[[DDXMLDocument alloc] initWithXMLString:data options:0 error:&error];NSArray *xmlItems=[ddDoc nodesForXPath:@"//url" error:&error];NSMutableArray *returnArray = [[NSMutableArray alloc] initWithCapacity:[xmlItems count]];for(DDXMLElement* itemElement in xmlItems){ DDXMLElement *element = [[itemElement nodesForXPath:@"loc" error:&error] objectAtIndex:0]; NSLog(@"valueasstring %@", element); [returnArray addObject:element];}\[/code\]I need the xmlRequest to return a string so I can get the XML but the [operation start] creates correct output but I can't put it in a string. How can I direct the output into a string?
 
Back
Top