Whats wrong with this code? it suppose to convert xml data to string and print it to the log?however it does not print anything!?
-(IBAction)request:(id)sender
{
开发者_运维问答 NSURL *url = [NSURL URLWithString:@"http://api.twitter.com/1/statuses/public_timeline.xml"];
theRequest = [[NSMutableURLRequest alloc] initWithURL:url];
theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
receivedData=[[NSMutableData data] retain];
NSString *s = [[NSString alloc] initWithData:receivedData encoding:NSUTF8StringEncoding];
NSLog(@"%@", s);
[s release];
//parser = [[NSXMLParser alloc] initWithData:receivedData];
//[parser setDelegate:self];
//[parser parse];
}
and idea?
Thanks in advance
receivedData=[[NSMutableData data] retain];
You're initializing empty data and afterwards, the url connection and url request are unused. The initialized data is empty.
精彩评论