0

I got to work on ios push notification for an web based app.

but I am practicing local push first while I am pending state in IOS developer program.

I found source code of local push and adjusted the code to two places where I thought the right place
- viewController.h, viewController.m.

below is the two files.

viewController.h file

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController
@property (strong, nonatomic) IBOutlet UITextField *timeTextField;
- (IBAction)onSaveAlertTime:(id)sender;
@end

viewController.m file

(IBAction)onSaveAlertTime:(id)sender {
// Do any additional setup after loading the view, typically from a nib.
UILocalNotification *localNofication = [[UILocalNotification alloc] init];
if (localNofication == nil) return;
NSDate *pushDate = [[NSDate date] dateByAddingTimeInterval:[timeTextField.text intValue]];

localNofication.fireDate = pushDate;
localNofication.timeZone = [NSTimeZone defaultTimeZone];
localNofication.alertBody = @"Local Push Notification!";
localNofication.alertAction = @"View";
localNofication.soundName = UILocalNotificationDefaultSoundName;
localNofication.applicationIconBadgeNumber = 1;

NSDictionary *userInfo = [NSDictionary dictionaryWithObject: @"오늘의 일정은 로컬푸시를 테스트하는 것 입니다" forKey:@"message"];

localNofication.userInfo = userInfo;
[[UIApplication sharedApplication] scheduleLocalNotification:localNofication];

}

It looks like my viewController.m file does not reconize timeTextField object which declared

in viewController.h file. What should I do to reconize timeTextField object?

4

2 回答 2

0

Did you synthesize your text field?

@synthesize timeTextField;

In the beginning of your .m file

于 2012-10-31T12:31:02.560 回答
0

Since it's a property of the object, you should reference in using self.timeTextField.text.

(When you report a problem, you should describe the actual symptoms. "does not reconize" is not easy to diagnose.)

于 2012-10-31T12:36:29.440 回答