我遇到了这样的情况。我希望删除可变数组中特定索引中的某个对象。因此,我有一个方法,通过传递索引来实现这一点。但它以NSUInteger作为参数。但我得到了一个整数值作为索引。当我调用我的方法时,参数值为null。下面是我的代码
for (int x=0; x<tempAry.count; x++) {
NSArray* temp = [tempAry objectAtIndex:x];
NSString* appoinment = [NSString stringWithFormat:@"%@",[temp valueForKey:@"AppointmentId"]];
if ([appoinment isEqualToString:appoinmentID_for_rejct]) {
//attention here
NSUInteger* index = (NSUInteger*)x;
[TableViewController removeIndexfromDuplicate:index];
}
}这里的索引得到了null..how,我能解决这个问题吗?索引不应该为空..。因为x不是空的value..please帮助我
发布于 2014-03-28 06:18:10
您在这里看到了什么(将整数转换为指针值,有什么特定的原因要做吗?):
//attention here
NSUInteger* index = (NSUInteger*)x;
[TableViewController removeIndexfromDuplicate:index];应该是这样的:
NSUInteger index = x;
[TableViewController removeIndexfromDuplicate:index];或者简单地使用x作为[TableViewController removeIndexfromDuplicate:x];
*备注:遵守良好的命名规则。TableViewController看起来像一门课!
https://stackoverflow.com/questions/22705474
复制相似问题