'UIAPPLICATION没有可见的@interface ..本地通知教程失败

时间:2013-02-09 02:05:47

标签: iphone

刚学习iPhone而我收到以下错误

    [app scheduledLocalNotifications:notification];

uiapplication没有可见的@interface声明了选择器schedulelocalnotifications

有人可以帮帮我吗。我确信它很简单,我只是没有意识到这是我的第一个教程

感谢

-(IBAction)createNotification{

NSLog(@"createNotification");

NSString *dateString = dateTextField.text;
NSString *textString = textTextField.text;

NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"MM-dd-yyyy HH:mm"];
[formatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:-18000]];

NSDate *alertTime = [formatter dateFromString:dateString];

UIApplication* app = [UIApplication sharedApplication];

UILocalNotification *notification = [[UILocalNotification alloc] init];
if (notification) {
    notification.fireDate = alertTime;
    notification.timeZone = [NSTimeZone defaultTimeZone];
    notification.repeatInterval = 0;
    notification.alertBody = textString;

    [app scheduledLocalNotifications:notification];
    [app presentLocalNotificationNow:notification];

}

}

1 个答案:

答案 0 :(得分:3)

scheduledLocalNotifications属性。

  

此属性包含一组UILocalNotification实例   表示当前计划的本地通知。你可以设置或   重置数组中的本地通知并访问它们。

阅读文档:http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIApplication_Class/Reference/Reference.html

在代码下方改为相似。

NSMutableArray *notifications = [[NSMutableArray alloc] init];
[notifications addObject:notification];
app.scheduledLocalNotifications = notifications;
//Equivalent: [app setScheduledLocalNotifications:notifications];
相关问题