Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 通知中心(OS X)-变量作为标题_Objective C_Macos_Nsusernotificationcenter - Fatal编程技术网

Objective c 通知中心(OS X)-变量作为标题

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

我对通知中心内容中的set变量有问题。这是我的密码

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];