我有一个运行Obj-C的C ++文件,但是Obj-C的东西似乎没有运行(它编译得很好)但我得到一个错误,说obj-c的东西是假设的(在这种情况下注册为growl)没有跑。
growlwrapper.mm
#import "growlwrapper.h"
@implementation GrowlWrapper
- (NSDictionary *) registrationDictionaryForGrowl {
return [NSDictionary dictionaryWithObjectsAndKeys:
[NSArray arrayWithObject:@"Upload"], GROWL_NOTIFICATIONS_ALL,
[NSArray arrayWithObject:@"Upload"], GROWL_NOTIFICATIONS_DEFAULT
, nil];
}
@end
void showGrowlMessage(std::string title, std::string desc) {
std::cout << "[Growl] showGrowlMessage() called." << std::endl;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[GrowlApplicationBridge setGrowlDelegate: @""];
[GrowlApplicationBridge
notifyWithTitle: [NSString stringWithUTF8String:title.c_str()]
description: [NSString stringWithUTF8String:desc.c_str()]
notificationName: @"Upload"
iconData: nil
priority: 0
isSticky: YES
clickContext: nil
];
[pool drain];
}
int main() {
showGrowlMessage("Hello World!", "This is a test of the growl system");
return 0;
}
growlwrapper.h
#ifndef growlwrapper_h
#define growlwrapper_h
#include <string>
#include <iostream>
#include <Cocoa/Cocoa.h>
#include <Growl/Growl.h>
using namespace std;
void showGrowlMessage(std::string title, std::string desc);
int main();
#endif
@interface GrowlWrapper : NSObject <GrowlApplicationBridgeDelegate>
@end
知道为什么不跑吗?
答案 0 :(得分:0)
您正在将growl委托设置为空字符串,而不是GrowlWrapper
类的实例。