0

i have a situation like this. i want to remove some object in a particular index in a mutable array. so i have a method for do that by passing the index. but it takes NSUInteger as a parameter. but i got an integer value as the index. when i call my method, the parameter value is null.. below is my code

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];

                }
            }

here the index got null..how can i fix this.? the index should not be null.. because x is not a null value..please help me

Darshana
  • 314
  • 2
  • 4
  • 22

1 Answers1

3

What you did see here (Converted an integer to pointer value, is there any specific reason to do ???):

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

It should be like this:

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

Or simply use x as [TableViewController removeIndexfromDuplicate:x];

*Side Note: Follow good naming convention. TableViewController looks like a class!!!

Anoop Vaidya
  • 46,283
  • 15
  • 111
  • 140
  • About side note : yes it is a class @Anoop . removeIndexfromDuplicate:x is a private method which is working like setter.. – Darshana Mar 28 '14 at 06:34