I am very new to Cocoa Touch and Objective-C but I've gotten the pretty big points down and I am experimenting with the UIKit. I have a action linked to a button that changes a label and fires a UILocalNotification and this is the action method:
- (IBAction)changeLabel:(id)sender {
self.LabelOne.text = @"WHAT UPPP!";
self.NotifyOne.alertBody = @"Testtttttt";
self.NotifyOne.alertAction = @"Got It.";
self.NotifyOne.fireDate = nil;
}
There are no errors or warnings, but it's just not firing. Is there anything wrong with my action method?
UPDATE
Here is the App Delegate initialization that contains the UILocalNotification
:
@interface LearnAppDelegate : NSObject <UIApplicationDelegate> {
UIButton *_ModifyLabelButton;
UILabel *_LabelOne;
UILocalNotification *_NotifyOne;
}
@property (nonatomic, retain) IBOutlet UILocalNotification *NotifyOne;
Are you ever scheduling the alarm? Here is code I use to fire alarms.
If you are wanting it show without a schedule (eg. when you press a button) then either use
UIAlertView
or add[application presentLocalNotificationNow:self.NotifyOne];
to your code.UPDATE
Remove IBOutlet and make both declarations of UILocalNotification the same name. For example:
Remember to
synthesize
in your implementation (.m) file.Also try this instead:
A
UILocalNotification
isn't going to fire if you don't provide it with afireDate
and schedule it with your application instance. If you're trying to immediately present some sort of alert, perhaps you should try usingUIAlertView
.