void getArrayOfFriends void NSArray friends getFriends VKRequest reque

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
- (void)getArrayOfFriends:(void(^) (NSArray *friends)) getFriends
{
VKRequest *request = [[VKApi friends] get:@{VK_API_FIELDS: @"id,first_name,last_name, sex, bdate, city, country, photo_100, photo_200, online, online_mobile, status", VK_API_ORDER: @"name"}];
[request executeWithResultBlock:^(VKResponse *response) {
if ([response.json isKindOfClass:NSDictionary.class]) {
NSDictionary *respDictionary = response.json;
if (respDictionary.allKeys.count == 2) {
NSArray *respFriends = respDictionary[@"items"];
NSMutableArray *friends = [[NSMutableArray alloc] init];
for (NSDictionary *friend in respFriends) {
VKUser *user = [[VKUser alloc] initWithDictionary:friend];
[friends addObject:user];
}
getFriends(friends);
}
}
} errorBlock:^(NSError *error) {
NSLog(@"%@", error);
}];
}