I am developing one application in that I have declared iVar as NSIndexPath object,but it shows as NSArray object in didSelectRowAtIndexPath. How it shows like that, what is the mistake from my side.
Please help me.
Thanks in advance.
Sample Code:
//.h file:
NSIndexPath *lastIndexPath;
//.m file:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
if([[default1 objectForKey:@"keyToRepeatString"] isEqualToString:[arrayRepeat objectAtIndex:i]])
{
lastIndexPath=indexPath;
repeatString=[default1 objectForKey:@"keyToRepeatString"];
}
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
int newRow = [indexPath row];
int oldRow = [lastIndexPath row];
}
int oldRow = [lastIndexPath row];........//Here lastIndexPath shows as NSArray obj?
Looks like a memory management problem :
That line doesn’t tell the indexPath to hang around 🙂
You will need to put this instead :
First it tells any previous lastIndexPath that you are done with it. Then it tells the indexPath not to be dealloced so the memory won’t be used for anything else (in your case, an NSArray).