0

Twitter ユーザーのリストを返す関数を作成しようとしていますが、関数が nsmutablearray を返すようにすることはできません。ここに私が実行するコードがあります

-(NSMutableArray*) getTwitterUsersInPosition: (Position*) position

{ // Twitter アカウントへのアクセスをリクエストする

ACAccountStore *accountStore = [[ACAccountStore alloc] init];
ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];

[accountStore requestAccessToAccountsWithType:accountType options:nil completion:^(BOOL granted, NSError *error){
    if (granted) {

        NSArray *accounts = [accountStore accountsWithAccountType:accountType];

        // Check if the users has setup at least one Twitter account

        if (accounts.count > 0)
        {
            ACAccount *twitterAccount = [accounts objectAtIndex:0];

            // Creating a request to get the info about a user on Twitter

                           NSArray *keys = [NSArray arrayWithObjects:@"geocode", @"count", nil];
            NSArray *objects = [NSArray arrayWithObjects:@"37.781157,-122.398720,100mi", @"2", nil];
            NSDictionary *dictionary = [NSDictionary dictionaryWithObjects:objects
                                                                   forKeys:keys];

            SLRequest *twitterInfoRequest = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodGET URL:[NSURL URLWithString:@"https://api.twitter.com/1.1/search/tweets.json"] parameters:dictionary];
            [twitterInfoRequest setAccount:twitterAccount];

            // Making the request

            [twitterInfoRequest performRequestWithHandler: ^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
                dispatch_async(dispatch_get_main_queue(), ^{

                    // Check if we reached the rate limit

                    if ([urlResponse statusCode] == 429) {
                        NSLog(@"Rate limit reached");
                        return;
                    }

                    // Check if there was an error

                    if (error) {
                        NSLog(@"Error: %@", error.localizedDescription);
                        return;
                    }

                    // Check if there is some response data

                    if (responseData) {

                        NSError *error = nil;
                        NSArray *TWData = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableLeaves error:&error];

                        NSMutableArray *usersArray= [[NSMutableArray alloc] init];

                        NSMutableArray* statuses= [(NSDictionary *) TWData objectForKey:@"statuses"];

                        for (NSDictionary* dict in statuses )
                        {
                            NSString* user = [[dict objectForKey:@"user"] objectForKey:@"screen_name"];
                            NSLog(@"%@",user);
                            [usersArray addObject:user];
                        }
                         return userArray; //Here it says "Return type 'NSMutabelArray *' must match previous type 'void' when block literal has unspecified return type


                    }

                });


            }];
        }
    } else {
        NSLog(@"No access granted");
    }
}];

}

ご協力いただきありがとうございます。

4

2 に答える 2