2
我想使用NSEvent,但是如果我嘗試訪問該類,則會出現錯誤。我起初以爲這是因爲我試圖從主要方法中使用它,但即使當我嘗試在課堂上使用它時,它仍然無法構建。爲什麼我無法訪問NSEvent?
這裏是我的代碼:
#import <Foundation/Foundation.h>
#import <appkit/NSEvent.h>
@interface Test : NSObject
@end
@implementation Test
-(id) init {
self = [super init];
if (self) {
NSLog(@"New Test Class");
NSLog(@"%@", [NSEvent class]);
}
return self;
}
@end
int main (int argc, const char * argv[])
{
@autoreleasepool {
NSUInteger eventMask = NSKeyDownMask;
Test *t = [[Test alloc] init];
/*id eventMonitor = [NSEvent addLocalMonitorForEventsMatchingMask:eventMask handler:^(NSEvent *incomingEvent)
{
NSEvent *result = incomingEvent;
NSLog(@"%i", (int)[result keyCode]);
return result;
}];*/
}
return 0;
}
這是我得到的錯誤:
如何添加框架或使用命令行?對不起,我是objective-c的新手。 – 2012-02-02 00:57:27
http://stackoverflow.com/questions/3352664/how-to-add-existing-frameworks-in-xcode-4 – 2012-02-02 01:04:17