Search code examples
iphoneiosnsexception

try and catch is not handling exception in iphone


i am using the following code to catch an error when ind.row is not a valid value or sometimes it becomes nil

@try {
        if(ind.row<[[treeNode flattenElements] count])
        {
            [self.mTableView scrollToRowAtIndexPath:ind atScrollPosition:UITableViewScrollPositionTop animated:YES];
        }


    }
    @catch (NSException *e) {
        NSLog(@"%@",e);

    }   

but when this code executes sometimes this error is occuring

Assertion failure in -[NSIndexPath row], /SourceCache/UIKit_Sim/UIKit-1262.60.3/UITableViewSupport.m:1948`

what may be the reason for this error and why exception is not being handled


Solution

  • actually it was already catching the exceptions...i had set the flag stop on objc exceptions.when i removed that it catching the exceptions.... as pointed out by @stilesCrisis the ind value was null at the time of this exception..sorry for the trble