2012-07-20 57 views
0

我有一個C++文件,也運行Obj-C的東西,但Obj-C的東西似乎沒有得到運行(它編譯好),但我得到一個錯誤,說obj-c的東西是想做的(在這種情況下注冊咆哮)沒有得到運行。@implement裏面.mm沒有跑?

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

您正在將您的咆哮委託設置爲空字符串,而不是您的GrowlWrapper類的實例。

+0

咆哮代表僅用於點擊後跟蹤和處理。它與註冊沒有任何關係。 – Steven 2012-07-20 12:42:54

+0

不正確,它也可以提供註冊字典。 – Sven 2012-07-20 13:19:31

+0

? Hrmmm我該怎麼做?你說它需要附加到我的GrowlWrapper類的實例?當你說實例時你的意思是什麼? ' - (void)blah'?我正在尋找https://github.com/dewind/real-growl,他們似乎將它傳遞給Ruby的Data_Struct thingy,但我不能這樣做?還有什麼我可以通過它的C + +嗎? – Steven 2012-07-20 13:40:52