Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 未捕获异常:ReferenceError:';非应用程序';是未定义的_Objective C - Fatal编程技术网

Objective c 未捕获异常:ReferenceError:';非应用程序';是未定义的

Objective c 未捕获异常:ReferenceError:';非应用程序';是未定义的,objective-c,Objective C,下面显示的代码给出了一个示例 #import <Foundation/Foundation.h> #import <AppKit/AppKit.h> @interface Main : NSObject { } @end @implementation Main +(void)main { NSLog(@"Hello world!"); NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

下面显示的代码给出了一个示例

#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
#导入
#进口
@主接口:NSObject{}
@结束
@实施主体
+(无效)主要
{
NSLog(@“你好,世界!”);
NSAutoreleasePool*池=[[NSAutoreleasePool alloc]init];
Napplication*anApplication=nil;
NSArray*屏幕阵列=零;
N分子*屏幕枚举数=零;
NSScreen*aScreen=nil;
NSWindowDepth*Depth=null;//删除常量
BOOL-exactMatch=NO;
a应用程序=[n应用程序共享应用程序];
screenArray=[NSScreen screens];
screenEnumerator=[screenArray objectEnumerator];
}
@结束

我正在使用windows,请浏览下面的链接qckapp.com/index.html?p=ObjC

试试看

#导入
我认为您的导入不包括非应用程序的标题

那是错误的。事实上,我认为问题在于你没有打电话。如果没有应用程序(带有用户界面),那么拥有应用程序对象就没有意义。如果你不想要一个用户界面,你可以不使用它

还要确保您正在链接AppKit框架。

您不能使用


只需检查一下编译器

您的编译器没有ui功能 你只需要做一些基本的事情 试试gnustep


祝你好运。

@appu:No.
NSApplicationLoad()
NSApplicationMain()
是函数,而不是对象。您必须选择其中一个来创建NSApplication的实例。@appu:No.
int suces=NSApplicationLoad()我正在使用windows,请浏览下面的链接@appu:我想我不能再帮你了。我从未使用过你链接到的编译器。如果它功能不全,我一点也不会感到惊讶。好的。感谢您的支持和指导。您使用的是哪个平台。我可以使用其他编译器在windows中制作上述程序吗?
#import <Cocoa/Cocoa.h>