Mountain Lion OSX 10.8的Hello世界代码显示了像iChat这样的通知

时间:2012-07-18 18:29:39

标签: objective-c cocoa osx-mountain-lion

是否有任何关于在Mountain Lion OSX 10.8(新通知中心)上显示问候语世界通知的示例。

为了增加视觉清晰度,我正在谈论的是: Notification Center Notification

2 个答案:

答案 0 :(得分:43)

在@Alexsander的一点帮助下我终于找到了答案。

NSUserNotification *notification = [[NSUserNotification alloc] init];
[notification setTitle:@"Hello World"];
[notification setInformativeText:@"Hello world message"];
[notification setDeliveryDate:[NSDate dateWithTimeInterval:20 sinceDate:[NSDate date]]];
[notification setSoundName:NSUserNotificationDefaultSoundName];
NSUserNotificationCenter *center = [NSUserNotificationCenter defaultUserNotificationCenter];
[center scheduleNotification:notification];

希望它可以帮助人们

答案 1 :(得分:10)

查找NSUserNotificationNSUserNotificationCenter