0
iPhone 응용 프로그램 개발에 새로운입니다. 이제 iPhone 용 알람 응용 프로그램을 개발 중입니다. 이 응용 프로그램에서 나는 UIDataPicker에서 데이터를 선택했습니다. 그런 다음 NSLocalNotification에 경보 버튼 동작으로 발사합니다. 그것은 처음으로 일하고 있습니다. 그런 다음 두 번째 시간 agin을 클릭하면 다시 작동하지만 시간도 동일합니다. 그것은 잘못 작동하고 있습니다.알람 응용 프로그램에 NSTimer를 설정하는 방법은 무엇입니까?
여기 NSTimer가 필요하다고 생각합니다. 나는 NSTimer를 사용하는 방법을 모른다. 또한이 타이머를 설정하는 방법도 배경 응용 프로그램을 만들고있다.
경고 알림을위한 개발 된 코드입니다.
- (void) saveButtonAction:(id)sender {
[[UIApplication sharedApplication] cancelAllLocalNotifications];
Class cls = NSClassFromString(@"UILocalNotification");
if (cls != nil)
{
Resource *resourceLoader = [[Resource alloc] init];
NSDictionary *prefDic = [resourceLoader getPlistDataAsDictionary:@"preference"];
NSString *musicName;
NSDate *selectedDateTime = [[NSDate alloc]init];
if (prefDic && [prefDic objectForKey:@"alarmtime"]) {
//firstVal_textField.text = [prefDic objectForKey:@"value1"];
NSLog(@"saravanan %@",[prefDic objectForKey:@"alarmtime"]);
selectedDateTime = [prefDic objectForKey:@"alarmtime"];
NSLog(@"saravanan periyasamy %@", selectedDateTime);
musicName = [NSString stringWithFormat:@"%@%@",[prefDic objectForKey:@"alarmmusic"],@".wav" ];
}
UILocalNotification *notif = [[cls alloc] init];
//notif.fireDate = [datePicker date];
notif.fireDate = selectedDateTime;
notif.timeZone = [NSTimeZone defaultTimeZone];
notif.alertBody = @"Alarm";
notif.alertAction = @"Show me";
//notif.repeatInterval = 0;
//notif.soundName = UILocalNotificationDefaultSoundName;
notif.soundName = musicName;
notif.applicationIconBadgeNumber = 1;
NSDictionary *userDict = [NSDictionary dictionaryWithObject:@"saravanan"
forKey:kRemindMeNotificationDataKey];
notif.userInfo = userDict;
[[UIApplication sharedApplication] scheduleLocalNotification:notif];
[notif release];
}
}
}