Reputation: 11851
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:
pldCell.stringData= [self reverseStringDate:[[[allJobTaskArray objectAtIndex:j] objectAtIndex:i] substringToIndex:10]];
when j
is 6 and i
is 36 simple because in allJobTaskArray
objectAtIndex: 6 objectAtIndex: 36 does not exist.[__NSCFArray objectAtIndex:]: index (36) beyond bounds (36)
pldCell
should equal @""
;
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]];
}
Upvotes: 2
Views: 219
Reputation: 415
Altogether it should look something like -
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];
if ([[allJobTaskArray objectAtIndex:j] count] > i) {
pldCell.stringData= [self reverseStringDate:[[[allJobTaskArray objectAtIndex:j] objectAtIndex:i] substringToIndex:10]];
} else {
pldCell.stringData = @"";
}
pldCell.cellSelected = NO;
[punchListData addObject:pldCell];
}
}
Upvotes: 1