Objective c 通知中心(OS X)-变量作为标题
我对通知中心内容中的set变量有问题。这是我的密码Objective c 通知中心(OS X)-变量作为标题,objective-c,macos,nsusernotificationcenter,Objective C,Macos,Nsusernotificationcenter,我对通知中心内容中的set变量有问题。这是我的密码 NSUserNotification *notification = [[NSUserNotification alloc] init]; [notification setTitle:@"version of app"]; [notification setInformativeText:@"message"]; // Delay of pop-up notification [notification setDeliveryDate:[NS
NSUserNotification *notification = [[NSUserNotification alloc] init];
[notification setTitle:@"version of app"];
[notification setInformativeText:@"message"];
// Delay of pop-up notification
[notification setDeliveryDate:[NSDate dateWithTimeInterval:0 sinceDate:[NSDate date]]];
// Sound of notification
//[notification setSoundName:NSUserNotificationDefaultSoundName];
NSUserNotificationCenter *center = [NSUserNotificationCenter defaultUserNotificationCenter];
[center scheduleNotification:notification];
如何将CbundLeversion添加到通知内容?虽然这与通知中心无关,但您应该使用
CbundLeversion
创建一个字符串
NSString *version = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"];
NSString *title = [NSString stringWithFormat:@"Version %@", version];
然后只需将title变量设置为title:
[notification setTitle:title];