开发者

objective-c how to convert xml to string?

开发者 https://www.devze.com 2023-02-02 14:52 出处:网络
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!?

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

精彩评论

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