TouchXML 读取 iPhone 应用程序的 twitter feed

发布于 2024-09-01 14:00:24 字数 2035 浏览 4 评论 0原文

所以我设法从 Twitter 获取提要并尝试解析它...... 我只需要提要中的以下字段: 名称、描述、时区和创建时间 我成功地提取了名称和描述..但是 time_zone 和created_at始终为零...以下是代码...

有人知道为什么这可能不起作用吗?

-(void) friends_timeline_callback:(NSData *)data{

    NSString *string = [[NSString alloc] initWithData:data  encoding:NSASCIIStringEncoding];
    NSLog(@"Data from twitter: %@", string);

    NSMutableArray *res = [[NSMutableArray alloc] init]; 
    CXMLDocument *doc = [[[CXMLDocument alloc] initWithData:data options:0 error:nil] autorelease]; 
    NSArray *nodes = nil; 

    //! searching for item nodes 
    nodes = [doc nodesForXPath:@"/statuses/status/user" error:nil]; 

    for (CXMLElement *node in nodes) 
    { 
        int counter; 
        Contact *contact  = [[Contact alloc] init]; 

        for (counter = 0; counter < [node childCount]; counter++) 
        { 
            //pulling out name and description only for the minute!!!
            if ([[[node childAtIndex:counter] name] isEqual:@"name"]){
                contact.name = [[node childAtIndex:counter] stringValue];

            }else if ([[[node childAtIndex:counter] name] isEqual:@"description"]) {

                // common procedure: dictionary with keys/values from XML node 
                if ([[node childAtIndex:counter] stringValue] == NULL){
                    contact.nextAction = @"No description";
                }else{
                    contact.nextAction = [[node childAtIndex:counter] stringValue];
                }

            }else if ([[[node childAtIndex:counter] name] isEqual:@"created_at"]){

                contact.date == [[node childAtIndex:counter] stringValue];

            }else if([[[node childAtIndex:counter] name] isEqual:@"time_zone"]){

                contact.status == [[node childAtIndex:counter] stringValue];
                [res addObject:contact];
                [contact release];
            }
        } 
    }
    self.contactsArray = res;
    [res release];
    [self.tableView reloadData];

}

预先感谢您的帮助!

菲奥娜

So I've managed to get the feed from twitter and am attempting to parse it...
I only require the following fields from the feed:
name, description, time_zone and created_at
I am successfully pulling out name and description.. however time_zone and created_at always are nil... The following is the code...

Anyone see why this might not be working?

-(void) friends_timeline_callback:(NSData *)data{

    NSString *string = [[NSString alloc] initWithData:data  encoding:NSASCIIStringEncoding];
    NSLog(@"Data from twitter: %@", string);

    NSMutableArray *res = [[NSMutableArray alloc] init]; 
    CXMLDocument *doc = [[[CXMLDocument alloc] initWithData:data options:0 error:nil] autorelease]; 
    NSArray *nodes = nil; 

    //! searching for item nodes 
    nodes = [doc nodesForXPath:@"/statuses/status/user" error:nil]; 

    for (CXMLElement *node in nodes) 
    { 
        int counter; 
        Contact *contact  = [[Contact alloc] init]; 

        for (counter = 0; counter < [node childCount]; counter++) 
        { 
            //pulling out name and description only for the minute!!!
            if ([[[node childAtIndex:counter] name] isEqual:@"name"]){
                contact.name = [[node childAtIndex:counter] stringValue];

            }else if ([[[node childAtIndex:counter] name] isEqual:@"description"]) {

                // common procedure: dictionary with keys/values from XML node 
                if ([[node childAtIndex:counter] stringValue] == NULL){
                    contact.nextAction = @"No description";
                }else{
                    contact.nextAction = [[node childAtIndex:counter] stringValue];
                }

            }else if ([[[node childAtIndex:counter] name] isEqual:@"created_at"]){

                contact.date == [[node childAtIndex:counter] stringValue];

            }else if([[[node childAtIndex:counter] name] isEqual:@"time_zone"]){

                contact.status == [[node childAtIndex:counter] stringValue];
                [res addObject:contact];
                [contact release];
            }
        } 
    }
    self.contactsArray = res;
    [res release];
    [self.tableView reloadData];

}

Thanks in advance for your help!!

Fiona

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

淡笑忘祈一世凡恋 2024-09-08 14:00:24

可能是一个错误,但为什么它们是双等号(==),通常用于条件检查

Might be a mistake but why are they double equals (==), usually used for a condition check

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文