Iphone 检索json数组对象的几个参数并在另一个函数中显示它们

Iphone 检索json数组对象的几个参数并在另一个函数中显示它们,iphone,objective-c,Iphone,Objective C,cellForRow方法中有一个json响应对象,如下所示: { geofenceType="a"; resourceType="b"; requestType="c"; monitoringType="d"; }, { geofenceType="a1"; resourcetype="b1"; requestType="c1"; monitoringType="d1"; }, ...and so on for different users. 我在每个用户前面都有一个按钮,因此只有所选用户的

cellForRow方法中有一个json响应对象,如下所示:

{
geofenceType="a";
resourceType="b";
requestType="c";
monitoringType="d";
},
{
geofenceType="a1";
resourcetype="b1";
requestType="c1";
monitoringType="d1";
}, ...and so on for different users.
我在每个用户前面都有一个按钮,因此只有所选用户的详细信息才能通过。因此,我通过类似以下内容的标签来完成此操作:

CellForRow:
{
myAray=json; (now this has the values of all users and myArray is declared in the .h file)
UIButton *b=[[UIButton alloc] initWithFrame:CGRectMake(230,0,40,40)];
[b addTarget:self action:@selector(buttonPressed:withEvent:)forControlEvents:UIControlEventsTouchUpInside];
b.tag=indexPath.row;
[cell addSubview:b];
}
-(void) buttonPressed:(id) sender withEvent: (UIEvent*) event{
UIButton *mybtn=(UIButton*) sender;
NSMutableArray * localArray;
localArray=[myArray objectAtIndex:mybtn.tag];
}

问题:引发异常,并且无法打印localArray。

您是否看到这些是不同的IVAR:

myAray=json;

[myArray objectAtIndex:mybtn.tag];

myArray可能由数据类型“Dictionary”组成

尝试此操作,而不是NSMUTABLEARRY*localArray

NSDictionary *dict =[myArray objectAtIndex:btn.tag];
NSLog(@"%@",dict);

请提供解决方案。我在这方面花了很多时间|将ivar的名称更改为myAray或myArray(这应该更好:))当然AppDelegate也可能是正确的-您确定您确实在那里有一个数组吗??将其记录在NSLog中(@“class is:%@,[[myArray objectAtIndex:btn.tag]class])让我们看看json的类型是NSArray。myArray也是如此。没错,但它包含{..}个花括号,表示字典..所以表面上说myArray是一个字典数组。上面的代码是否有效?你能给我myArray的输出吗?首先,为什么你要在“cellForRow”中加载myArray的数据,建议在viewDidLoad或其他函数中加载它?哦,注销!我已经提供了一个日志来复制粘贴,只是我在问题中粘贴了它。