I have this section of code here:
for (int i = 0; i<[taskData count]; i++)
{
for (int j=0; j<[allJobTaskArray count]; j++)
{
NSLog(@"%d", i);
NSLog(@"%d", j);
PunchListDataCell *pldCell = [[[PunchListDataCell alloc]init] autorelease];
pldCell.stringData= [self reverseStringDate:[[[allJobTaskArray objectAtIndex:j] objectAtIndex:i] substringToIndex:10]];
pldCell.cellSelected = NO;
[punchListData addObject:pldCell];
}
}
Now let me explain:
- taskData count is 57 and is a NSArray
- allJobTaskArray count is 12 and is a NSMutableArray
- This code will crash at this line:
pldCell.stringData= [self reverseStringDate:[[[allJobTaskArray objectAtIndex:j] objectAtIndex:i] substringToIndex:10]];whenjis 6 andiis 36 simple because inallJobTaskArrayobjectAtIndex: 6 objectAtIndex: 36 does not exist. - This is the error I am getting:
[__NSCFArray objectAtIndex:]: index (36) beyond bounds (36) - What I am trying to do is if the item does not exist, then
pldCellshould equal@"";- My question is how would I check if I am item exist or not ?
I have tried the following:
if([[allJobTaskArray objectAtIndex:j] objectAtIndex:i] == [NSNull null]){
pldCell.stringData = @"";
}else{
pldCell.stringData= [self reverseStringDate:[[[allJobTaskArray objectAtIndex:j] objectAtIndex:i] substringToIndex:10]];
}