[FBRequestConnection startWithGraphPath:不使用队列

时间:2014-06-04 12:17:25

标签: ios objective-c facebook facebook-graph-api

Problem->我只是想取很多不在主队列但在不同队列上的朋友,在队列中我也称为登录,openSession方法进行登录。我想尝试获取分数

第1步 - > - (void)requestcallerWithQueue在这个方法中我试图获取由我创建的队列内的得分(不是主队列)然后FBRequestConnection startWithGraphPath:FBRequestConnection中的方法调用startWithGraphPath: NOT RESPONDING

步骤2 - > - (void)requestcallerWithoutQueue在这个方法中我试图获取由我创建的队列内的得分(不是主队列)然后FBRequestConnection startWithGraphPath:FBRequestConnection中的方法调用startWithGraphPath:回复

          **CODE IS BELOW FOR REFERENCE**


-(void)fetchscoreWithCallback:(void (^)(NSDictionary*))callback
 {

    NSMutableDictionary* params =   [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                 [NSString stringWithFormat:@"%ld", (long)10],     @"score",
                                 nil];

// [NSString stringWithFormat:@"%llu/scores", lintFBFriendId]
    [FBRequestConnection startWithGraphPath:@"245526345633359/scores"
                             parameters:params
                             HTTPMethod:@"GET"
                      completionHandler:^(FBRequestConnection *connection, id result, NSError *error)
 {
     NSLog(@"result->%@",result);


 }

}
  

不工作

-(void)requestcallerWithQueue
{

    dispatch_queue_t some_queue = dispatch_queue_create("some.queue.name", NULL);
    dispatch_async(some_queue, 
   ^{
       [self  fetchscoreWithCallback:callback];
    }];

}
  

WORKING

-(void)requestcallerWithoutQueue
{

       [self  fetchscoreWithCallback:callback];

}

1 个答案:

答案 0 :(得分:0)

FBRequestConnection使用NSURLConnection,默认情况下要求调用线程具有运行循环。对于非主线程,您必须自己管理运行循环或将工作分派回主队列。对于某些资源,请查看:

http://coc24hours.blogspot.com/2012/01/using-nsrunloop-and-nsurlconnection.html

NSURLConnection needs a NSRunLoop to execute?

http://iosdevelopmentjournal.com/blog/2013/01/27/running-network-requests-in-the-background/