0

我有一个 C++ 文件,它也运行 Obj-C 的东西,但 Obj-C 的东西似乎没有运行(它编译得很好),但我收到一个错误,说 obj-c 应该做的东西(在这种情况下注册咆哮)没有跑。

咆哮者.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;
}

咆哮包装器.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

知道为什么它没有被运行吗?

4

1 回答 1

0

您将咆哮委托设置为空字符串,而不是您的GrowlWrapper类的实例。

于 2012-07-20T06:12:00.330 回答