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 に答える