I am a new iPad developer.
I am implementing UIPopover on button click, and popover contains integer value,
when i trying to fill my array with integers it shows me, SIGABRT: index 3 beyond bounds i am unable to see my log, app crashes.
here is my code snippet:
-(void)btnClick:(id)sender {
for (int i=3; i<=31; i++) {
[remindarray addObject:[NSNumber numberWithInteger:i]];
NSLog(@"no=%@",[remindarray objectAtIndex:i]);
}
UIViewController* popoverContent = [[UIViewController alloc]init];
UIView* popoverView = [[UIView alloc] initWithFrame:CGRectMake(110, 0, 500, 4)];
popoverTable = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, 250, 665) style:UITableViewStylePlain];
[popoverTable setDelegate:(id<UITableViewDelegate>)self];
[popoverTable setDataSource:(id<UITableViewDataSource>)self];
[self.view addSubview:popoverTable];
[popoverTable release];
[popoverView addSubview:popoverTable];
popoverContent.view = popoverView;
popoverContent.contentSizeForViewInPopover = CGSizeMake(250, 600);
self.popoverController = [[UIPopoverController alloc]
initWithContentViewController:popoverContent];
[self.popoverController presentPopoverFromRect:CGRectMake(100,0, 535, 35)
inView:self.view permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES];
[popoverView release];
[popoverContent release];
}
and finally remind array i am passing to cellForRowAtIndexPath
code:
...
cell.textLabel.text=[remindarray objectAtIndex:indexPath.row];
...
Your for loop starts from 3, so in the array starts by 0 items, then you insert 1 item and you try to log the item at index 3, which is still not inside the array
A quick fix is by
Change
to
Or by starting the array from 0
Also you will need to change
to