1

我试过这段代码:

NSCalendar * calendar = [NSCalendar autoupdatingCurrentCalendar];
NSDateComponents * dateComponents = [[NSDateComponents alloc] init];
[dateComponents setDay:11];
[dateComponents setMonth:3];
[dateComponents setYear:2013];
[dateComponents setHour:6];
[dateComponents setMinute:00];
NSDate * date = [calendar dateFromComponents:dateComponents];
UILocalNotification * localNotification = [[UILocalNotification alloc] init];
[localNotification setFireDate:date];
[localNotification setTimeZone:[NSTimeZone defaultTimeZone]];
[localNotification setAlertBody:@"E' il primo di ottobre"];
[localNotification setAlertAction:@"Apri applicazione"];
[localNotification setSoundName:UILocalNotificationDefaultSoundName];
[localNotification setApplicationIconBadgeNumber:17];
NSArray * oggetti = [NSArray arrayWithObjects:@"Mangiare", @"Bere", nil];
NSArray * chiavi = [NSArray arrayWithObjects:@"azione1", @"azione2", nil];
NSDictionary * dictionary = [[NSDictionary alloc] initWithObjects:oggetti forKeys: chiavi];
[localNotification setUserInfo:dictionary];
[[application allocsharedApplication] scheduledLocalNotifications:localNotification];

最后一行给了我这个错误:“'UIIApplication' 没有可见的@interface 声明选择器'allocsharedApplication'”。!?!?!?

4

1 回答 1

2

最后一行是错误的。正确的是:

[application scheduleLocalNotifications:localNotification];
于 2013-03-12T13:37:18.757 回答