【发布时间】:2015-10-20 04:04:25
【问题描述】:
为什么 ObjC 程序会卡住? 我是 ObjC 的新手,正在尝试通过命令在 Linux 系统上编译它:
gcc $(gnustep-config --objc-flags) *.m $(gnustep-config --base-libs)
代码如下:
int main (int argc, const char * argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
Rect * r = [[Rect alloc]initWithWidth:30 height:50];
NSLog(@"%f", [r height]);
[pool drain];
return 0;
}
//=====
#import <Foundation/Foundation.h>
@interface Rect : NSObject <NSCopying> {
}
@property double width;
@property double height;
- (Rect *) initWithWidth:(double)w
height:(double)h;
- (double) height;
//...
//=====
@implementation Rect
- (Rect *) initWithWidth:(double)w
height:(double)h
{
self.width = w;
self.height = h;
return [super init];
}
- (double) height
{
return self.height;
}
// ...
【问题讨论】:
标签: objective-c