Quantcast
Viewing all articles
Browse latest Browse all 2

Answer by Prabhjot Singh Gogana for how to set NSTimer for alarm application?

The set button is wired up to run amethod calledscheduleNotification in theview controller which uses theUILocalNotification class toschedule a notification. The codelooks as follows:

   (void )scheduleNotification  { [reminderText resignFirstResponder]; [[ UIApplication sharedApplication] cancelAllLocalNotifications];Class cls = NSClassFromString(@ "UILocalNotification" );  if (cls != nil)    { UILocalNotification *notif = [[cls alloc] init];    notif.fireDate = [datePicker date];    notif.timeZone = [ NSTimeZone defaultTimeZone];    notif.alertBody = @ "Did you forget something?" ;    notif.alertAction = @ "Show me" ;    notif.soundName = UILocalNotificationDefaultSoundName ;       notif.applicationIconBadgeNumber = 1 ; NSDictionary *userDict = [       NSDictionary dictionaryWithObject:reminderText.text          forKey:kRemindMeNotificationDataKey];    notif.userInfo = userDict;      [[ UIApplication sharedApplication] scheduleLocalNotification:notif];    [notif release];}}

Viewing all articles
Browse latest Browse all 2

Trending Articles