nsusernotification

Mac Mountain Lion send notification from CLI app

天涯浪子 提交于 2019-11-27 19:30:39
How can I send a notification to the notification center from a command line app? My attemps so far compile and run, but don't succeed in notifying me. Example #import <Cocoa/Cocoa.h> int main(int argc, const char * argv[]) { NSLog(@"Running notifications"); NSUserNotification *note = [[NSUserNotification alloc] init]; [note setTitle:@"Test"]; [note setInformativeText:@"Woot"]; NSUserNotificationCenter *center = [NSUserNotificationCenter defaultUserNotificationCenter]; [center scheduleNotification: note]; return 0; } I then compile like: clang -framework cocoa /tmp/Notes.m and I get 2012-07-29

UserNotifications cancel, swift3

耗尽温柔 提交于 2019-11-27 03:26:31
问题 I'm working on app where user can set time for everyday local notification, then I have an option to enable or disable these notifications. My question how I can disable/cancel already setted notification? Here in one of this IFs I need to cancel notif override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { if (indexPath as NSIndexPath).row == 1 && switchiBtn.isOn == false { return 0.0 } if (indexPath as NSIndexPath).row == 2 { if switchiBtn.isOn ==