下面显示的代码给出了一个例外
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
@interface Main : NSObject { }
@end
@implementation Main
+(void)main
{
NSLog(@"Hello world!");
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSApplication *anApplication = nil;
NSArray *screenArray = nil;
NSEnumerator *screenEnumerator = nil;
NSScreen *aScreen = nil;
NSWindowDepth *depths = null;//remove const
BOOL exactMatch = NO;
anApplication = [NSApplication sharedApplication];
screenArray = [NSScreen screens];
screenEnumerator = [screenArray objectEnumerator];
}
@end
我正在使用Windows,请浏览以下链接qckapp.com/index.html?p=ObjC
答案 0 :(得分:0)
尝试
#import <Cocoa/Cocoa.h>
我认为您的导入不包含NSApplication的标题。
那是错的。实际上,我认为问题在于你没有打电话给NSApplicationMain()。如果您没有应用程序(具有用户界面),则拥有应用程序对象并没有多大意义。如果您不想要用户界面,则可能会使用NSApplicationLoad()。
还要确保链接AppKit框架。
答案 1 :(得分:0)
您无法使用http://qckapp.com/index.html?p=ObjC
完成此操作只需浏览编译器http://www.gnustep.org
答案 2 :(得分:0)
你的编译器没有ui的功能 你只需要用http://qckapp.com/index.html?p=ObjC作为基础知识 尝试gnustep
祝你好运。