- (void)checkSelected:(NSMutableArray *)dataUser
{
NSNumber * number = [[NSUserDefaults standardUserDefaults]objectForKey:@"treatment"];
for (NSInteger i = 0; i < dataUser.count; i++)
{
Treatment *treatment = (Treatment *)[dataUser objectAtIndex:i];
if ([treatment.treatment_id isEqualToNumber:number])
{
NSIndexPath *indexpath = nil;
//indexpath.row = i;
DLog(@"index path:%d",indexpath.row);
TreatementUserCell *cell = (TreatementUserCell*) [self.treatementUserTable cellForRowAtIndexPath:indexpath];
if (cell.accessoryType == UITableViewCellAccessoryCheckmark ) {
cell.accessoryType = UITableViewCellAccessoryNone;
UIImageView *image= [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"pick.png"]];
cell.accessoryView = image;
}
break;
}
}
}
我想设置indexPath.row = i,但indexPath是readonly。我该如何设置?
答案 0 :(得分:0)
阅读NSIndexPath文档以发现方法indexPathForRow:inSection:
。
答案 1 :(得分:0)
NSIndexPath
包含Rows
和Sections
,请尝试使用此代码为NSIndexPath
分配值
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:i inSection: section];