开发者

objective-c how to convert xml to string?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜