@机具内部.mm未运行

@implement inside .mm not being ran?

本文关键字:运行 mm 内部      更新时间:2023-10-16

我有一个C++文件,它也运行Obj-C的东西,但Obj-C东西似乎没有运行(它编译得很好),但我收到一个错误,说Obj-C应该做的东西(在本例中为growl注册)没有运行。

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

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

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