I'm having a weird error popping up. It's listing that my app is
Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'
What puzzles me is that the app runs perfectly fine in the simulator, but when I go to test it on my device I get that error. I've isolated the problem to the line of code below:
updatingTracker = [userDatas objectAtIndex:repeatCount];
Here is the rest of the relevant code:
[self getUserDatas];
[self timerDidFire];
-(void) getUserDatas
{
userDatas = [[NSMutableArray alloc] init];
NSUserDefaults *userdef = [NSUserDefaults standardUserDefaults];
int count = [[userdef objectForKey:@"user_count"] intValue];
for(int i=0;i<count;i++)
{
NewTracker *newtrack=[[NewTracker alloc] init];
newtrack.FromCurrency = [userdef objectForKey:[NSString stringWithFormat:@"from_string_%d",i]];
newtrack.ToCurrency = [userdef objectForKey:[NSString stringWithFormat:@"to_string_%d",i]];
newtrack.savedCurrency = [userdef objectForKey:[NSString stringWithFormat:@"save_currency_%d",i]];
newtrack.userTarget = [userdef objectForKey:[NSString stringWithFormat:@"user_target_%d",i]];
newtrack.trackerId = [userdef objectForKey:[NSString stringWithFormat:@"tracker_id_%d",i]];
newtrack.realtimeBase = [userdef objectForKey:[NSString stringWithFormat:@"realtime_base_%d",i]];
newtrack.realtimeTarget = [userdef objectForKey:[NSString stringWithFormat:@"realtime_target_%d",i]];
newtrack.realtimeUSD = [userdef objectForKey:[NSString stringWithFormat:@"realtime_USD_%d",i]];
[userDatas addObject:newtrack];
}
}
- (void) timerDidFire
{
NSLog(@"bug finder");
updatingTracker = [userDatas objectAtIndex:repeatCount];
[self chartconnectionStart:@"3m"];
}
Any ideas or help on why this is happening or how to fix it would be appreciated.