is there any reason why ECGraph would run fine on the simulator, but yet give me this error when i run it on my device:
2012-08-24 01:57:18.543 Portfolio[3538:9
You are trying to get NSDateComponents from a nil NSDate like that:
NSCalendar* gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDate* fromDate = nil;
NSDate* toDate = [NSDate date];
unsigned int components = NSYearCalendarUnit | NSDayCalendarUnit | NSMonthCalendarUnit | NSWeekCalendarUnit | NSWeekdayCalendarUnit | NSHourCalendarUnit;
NSDateComponents* dateComponents = [gregorian components:uintFlags fromDate:fromDate toDate:toDate options:0];
Probably a simple check can be useful:
NSDate* fromDate = nil;
NSDate* toDate = [NSDate date];
NSDateComponents* dateComponents = nil;
if(fromDate != nil)
{
NSCalendar* gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
unsigned int components = NSYearCalendarUnit | NSDayCalendarUnit | NSMonthCalendarUnit | NSWeekCalendarUnit | NSWeekdayCalendarUnit | NSHourCalendarUnit;
dateComponents = [gregorian components:uintFlags fromDate:fromDate toDate:toDate options:0];
}