简体   繁体   中英

Hello world code for Mountain Lion OSX 10.8 showing notification like iChat

Is there any example for showing a hello world notification on Mountain Lion OSX 10.8 (the new notification center).

Just to add visual clarity here is what I am talking about: 通知中心通知

I finally found answer after a little help from @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];

Hope it helps people

查找NSUserNotificationNSUserNotificationCenter

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM