Question

i'm making an iOS app using VKSdk. I want to copy data from response.json[@"items"](it's nsarray,response.json its nsdictionary) to my nsarray. Here is my code:

VKRequest * getWall = [VKRequest requestWithMethod:@"wall.get" andParameters:@{VK_API_OWNER_ID : @"1"} andHttpMethod:@"GET"];
[getWall executeWithResultBlock:^(VKResponse * response) {
    _vk_array=[[NSArray alloc]initWithArray:response.json[@"items"]];
     NSLog(@"%@",_vk_array);//shows null
     NSLog(@"%@",response.json[@"items"]);//shows ok
} errorBlock:^(NSError * error) {
    if (error.code != VK_API_ERROR) {
        [error.vkError.request repeat];
    }
    else {
        NSLog(@"VK error: %@", error);
    }
}];

I also trying to use just this code

_vk_array=response.json[@"items"]

But it still shows "null". Am i doing something wrong?

PS:

NSLog(@"%hhd",([response.json[@"items"] isKindOfClass:[NSArray class]]));//shows 1
Was it helpful?

Solution

Hi you can use it to copy an array object into another array.

NSArray *copyArray = [NSArray arrayWithArray:yourArray];

Thanks

OTHER TIPS

[response.json[@"items" 
    _vk_array=[[NSArray alloc]initWithArray:response.json[@"items"]];
     NSLog(@"%@",_vk_feed);//shows null

here you are assigning value to _vk_array But you are tracing value of _vk_feed.

Also, [response.json[@"items" is incomplete.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top