Objective c 获取tweet的地理位置

Objective c 获取tweet的地理位置,objective-c,twitter,geolocation,Objective C,Twitter,Geolocation,我正在进行推特搜索,需要获得每条推特的确切位置,以便在地图上绘制。我已经设置了核心位置,我的“获取推文”代码如下 我目前正在循环获取文本组件,但我不确定如何获取tweet附带的位置组件。您将看到下面的几行,我已经添加到循环中,以尝试提取位置,但是它显示为空/null •我是否将NSString*twitlocation定位在循环中的正确位置?当我运行objectAtIndex:0时,收集的位置是否会与我从不同数组中调用的每条tweet的正确文本相匹配,即tweet 1中的文本与tweet 1中的

我正在进行推特搜索,需要获得每条推特的确切位置,以便在地图上绘制。我已经设置了核心位置,我的“获取推文”代码如下

我目前正在循环获取文本组件,但我不确定如何获取tweet附带的位置组件。您将看到下面的几行,我已经添加到循环中,以尝试提取位置,但是它显示为空/null

•我是否将NSString*twitlocation定位在循环中的正确位置?当我运行objectAtIndex:0时,收集的位置是否会与我从不同数组中调用的每条tweet的正确文本相匹配,即tweet 1中的文本与tweet 1中的位置相匹配为什么twitterLocation的日志为空我将位置放在NSString中以添加到数组中是正确的,还是应该是另一个对象

供参考

  • 所有对象都已在.h文件中声明-TwitterText工作正常,我可以获得每个tweet的tweets文本-twitterLocation是一个NSMutableArray
谢谢


你在寻找什么?我的意思是“url”你有没有试过获取一条推特,你知道它附带了地理位置数据?很可能你正在检索的推特没有相关的元数据,因此你得到的是零。最后的标记是用于特定搜索的(即它将有一个与之相关联的搜索词)-我知道这部分是有效的。想象一下搜索词是与tweets相关联的关键字。ale0xb,这就是问题所在-我如何搜索以确保收到地理数据,然后如何像使用objectForKey:@“text”一样通过tweets循环提取这些数据?
- (void)fetchTweets
        {
            AppDelegate *delegate = (AppDelegate*)[[UIApplication sharedApplication]delegate];


            //NSLog(@"phrase carried over is %@", delegate.a);

            // Do a simple search, using the Twitter API
            TWRequest *request = [[TWRequest alloc] initWithURL:[NSURL URLWithString:
                                                                 [NSString stringWithFormat:@"http://search.twitter.com/search.json?q=%@", delegate.a]] 
                                                     parameters:nil requestMethod:TWRequestMethodGET];

            // Notice this is a block, it is the handler to process the response
            [request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error)
             {
                 if ([urlResponse statusCode] == 200) 
                 {
                     // The response from Twitter is in JSON format
                     // Move the response into a dictionary and print
                     NSError *error;        
                     NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseData options:0 error:&error];
                     //NSLog(@"Twitter response: %@", dict);

                     NSArray *results = [dict objectForKey:@"results"];


                     //Loop through the results


                     for (NSDictionary *tweet in results) {
                         // Get the tweet
                         NSString *twittext = [tweet objectForKey:@"text"];
                         //looping through to also get the location of each tweet
                         NSString *twitlocation = [tweet objectForKey:@"location"];

                         // Save the tweet to the twitterText array
                         [_twitterText addObject:twittext];
                         //adding the twitlocation to the location array
                        [twitterLocation addObject:twitlocation];
                     }

                     dispatch_async(dispatch_get_main_queue(), ^{

        [self.tableView reloadData];

                     });


                      NSLog(@"MY ************************LOCATION************** %@", twitterLocation);


                 }

                 else
                     NSLog(@"Twitter error, HTTP response: %i", [urlResponse statusCode]);
             }];



        }