0

私はこれに夢中になっています。メインスレッドからUIを更新する必要があることを知っており、performSelectorOnMainThreadメソッドとprogressView更新のラップの両方を試しましたdispatch_async( dispatch_get_main_queue(), ^{ update progressView });

//facebook request
FBRequest *friendsRequest = [FBRequest requestForGraphPath:@"me/friends?fields=id,name,birthday"];
[friendsRequest startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
    //user's friends
    NSArray *friends = [result objectForKey:@"data"];

    //counter
    int i = 0;

    //iterate through array of friends
    for (NSDictionary<FBGraphUser> *friend in friends)
    {
        //do some work here

        //update progressView
        float progress = (float)i/(float)[friends count];
        [[self progressView] setProgress:progress animated:YES];

        i++;
    }
}];

ありがとう!

4

0 に答える 0