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