从NSMultableArray转换为NSInteger

时间:2013-08-06 12:43:16

标签: objective-c

当我尝试将NSMutableArray的一部分转换为NSInteger时,我得到九位数(可能是扇区数),而不是该部分的值。

NSInteger i = [_tableData[1][@"likes"][@"count"] intValue];

_tableData - 从vk.com服务器转换回答

NSMutableArray *_tableData;
//------------------

- (void)viewDidLoad
{
    _tableData = [[NSMutableArray alloc] init];
    [[VKConnector sharedInstance]
    setDelegate:self];
    [[VKConnector sharedInstance] startWithAppID:@"3541027"
    permissons:@[@"wall"]];
}

#pragma mark - VKConnectorDelegate

- (void)VKConnector:(VKConnector *)connector accessTokenRenewalSucceeded:(VKAccessToken *)accessToken
{
    [[VKUser currentUser] setDelegate:self];
    [[VKUser currentUser] wallGet:@{@"owner_id":@"-44554509",@"count":@"100"}];
}

#pragma mark - VKRequestDelegate

- (void)VKRequest:(VKRequest *)request response:(id)response
{
    _tableData = response[@"response"];
    [_mainList reloadData];
}

enter image description here

1 个答案:

答案 0 :(得分:0)

您没有转换NSMutableArray,而是转换包含的任何对象。即使这样,它也有点令人困惑:

NSInteger i = [_tableData[1][@"likes"][@"count"] intValue];

...所以tableData可能包含索引1处的字典,而该字典又包含likes键下的另一个字典,其后包含NSValuecount键下。这就是我假设的,但事实上你的嵌套数组/字典似乎很可能包含其他内容。

您应该调试应用程序以准确确定您正在访问的对象。您可以使用断点或添加一些日志语句(或两者)来执行此操作。