Since i just cant get a good answer for this and spend so much time on this, i will ask my question in details
All i want is to create an alarm according to date picker.
setting alarm to 10 seconds from now, is works great .
UIDatePicker, is works (print the date-but not the date i have picked, but 3 hours later)
i know there is an issue with local times, but i just cant find any good explanation.
my propose, and i guess that almost everyone,is not getting involve in local times, but to take each user’s clock, and set alarm according to his time.
my code, is not working, i dont know why. its not firing(only if i set it to 10 seconds later)
please, i know that time zone should be different or something, but if you can explain what exactly to do and how, that would be great . thanks.
this is the code :
-(void)setDatePicker
{
CGRect pickerFrame = CGRectMake(0,265,0,0);
UIDatePicker *myPicker = [[UIDatePicker alloc] initWithFrame:pickerFrame];
[myPicker addTarget:self action:@selector(pickerChanged:) forControlEvents:UIControlEventValueChanged];
[[[CCDirector sharedDirector] view] addSubview:myPicker];
[myPicker release];
}
-(void)pickerChanged:(UIDatePicker*) datePicker
{
date=datePicker.date;
NSLog(@"value: %@",date);
}
and the local notification :
-(void) scheduleNotificationForDate: (NSDate*)theDate
{
/* Here we cancel all previously scheduled notifications */
[[UIApplication sharedApplication] cancelAllLocalNotifications];
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
//NSDateFormatter *dateFormat = [[[NSDateFormatter alloc]init]autorelease];
//[dateFormat setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
//NSDate *notificationDate = [dateFormat stringFromDate:theDate];
localNotification.fireDate = theDate;
NSLog(@"Notification will be shown on: %@",localNotification.fireDate);
localNotification.timeZone = [NSTimeZone defaultTimeZone];
localNotification.alertBody = [NSString stringWithFormat:
@"Your notification message"];
localNotification.alertAction = NSLocalizedString(@"View details", nil);
localNotification.soundName = UILocalNotificationDefaultSoundName;
localNotification.applicationIconBadgeNumber = -1;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
}
i got it .
i had to change the format and it worked.
nothing that relates to zones.