Facebook API - How to cancel Graph Request

后端 未结 9 1052
既然无缘
既然无缘 2020-12-16 04:06

I occasionally need to cancel a FaceBook graph request, but there seems to be no cancel or similar method in their API to do so. At the moment, crashes sometimes occur as th

9条回答
  •  臣服心动
    2020-12-16 05:01

    Try this instead of using NSTimer:

    FBRequest *fbRequest = [facebook requestWithGraphPath:@"me" andDelegate:self];
    [self performSelector:@selector(fbRequestTimeout:) withObject:fbRequest afterDelay:30];
    
    - (void)fbRequestTimeout:(FBRequest *)fbRequest
    {
        [fbRequest.connection cancel];
        [fbRequest setDelegate:nil];
    }
    

提交回复
热议问题