我在 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 不被打印。