0

我有这样的情况。我想删除可变数组中特定索引中的一些对象。所以我有一种方法可以通过传递索引来做到这一点。但它需要 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];

                }
            }

这里索引为空..我该如何解决这个问题。?索引不应该为空..因为 x 不是空值..请帮助我

4

1 回答 1

3

您在此处看到的内容(将整数转换为指针值,是否有任何具体原因要做???):

//attention here
NSUInteger* index = (NSUInteger*)x;
[TableViewController removeIndexfromDuplicate:index];

它应该是这样的:

NSUInteger index = x;
[TableViewController removeIndexfromDuplicate:index];

或者简单地x用作[TableViewController removeIndexfromDuplicate:x];

*旁注:遵循良好的命名约定。TableViewController好像上课!!!

于 2014-03-28T06:18:10.380 回答