我在我的 .h 中声明了一个 NSArray
@interface DevicePreferencesController : UITableViewController < UIAlertViewDelegate >{
NSArray *plist;
UITextField *deviceName;
}
该数组用于从 URL 加载 plist 数据
这是我得到的plist
plist:(
{
category = 11;
id = 1;
name = light1;
},
{
category = 11;
id = 5;
name = window;
},
{
category = 12;
id = 2;
name = dimmer2;
},
{
category = 23;
id = 3;
name = win;
}
)
我通过 tableView 显示它
如果我选择了单元格
它会弹出一个带有textField的alertView,它可以重命名plist中的数据
这是 alertView 的按钮操作
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if ([alertView tag]==1) {
if (buttonIndex == 1){
[request setPostValue:[[self.plist objectAtIndex:indexPath.row] valueForKey:@"id"] forKey:@"id"];
[request setPostValue:deviceName.text forKey:@"name"];
[request startSynchronous];
}
}
}
但是我在这里遇到错误“indexPath”未声明!
为什么 ?plist 是一个数组,为什么我不能从数组中获取 indexPath ???