cfUserNotificationCreate的工作示例

时间:2015-07-27 16:13:11

标签: xcode macos

我正在寻找cfusernotificationcreate()的工作示例 或cfusernotificationNotify()

我尝试了几个选项但对我没用。

1 个答案:

答案 0 :(得分:0)

这个适合我。

const void * keys [] =     {         kCFUserNotificationAlertHeaderKey,         kCFUserNotificationAlertMessageKey,         kCFUserNotificationCheckBoxTitlesKey,         kCFUserNotificationPopUpTitlesKey     };     CFTypeRef texKeys [3] = {CFSTR(" 1"),CFSTR(" 2"),CFSTR(" 3")};     CFArrayRef texVals = CFArrayCreate(NULL,texKeys,3,& kCFTypeArrayCallBacks);

CFTypeRef paramKeys[4] = { CFSTR("1"), CFSTR("2"), CFSTR("3"), CFSTR("4") };
CFArrayRef paramVals = CFArrayCreate( NULL, paramKeys, 4, &kCFTypeArrayCallBacks);

const void* values[] =
{
    CFSTR("VBNIO"),
    CFSTR("parameters"),
    paramVals,
    texVals
};
CFDictionaryRef dict = CFDictionaryCreate(NULL, keys, values, sizeof(keys)/sizeof(*keys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);

SInt32 err32 = 0;
CFUserNotificationRef notif = CFUserNotificationCreate(NULL, 0, kCFUserNotificationPlainAlertLevel, &err32, dict);

CFOptionFlags responseFlags = 0;
SInt32 response = CFUserNotificationReceiveResponse(notif, 120, &responseFlags);
CFRelease(dict);

知道如何填写初始按钮值吗?