日期:2014-05-16 浏览次数:20745 次
虽然很折腾,但当看到程序输出那一刻,心里一阵暗爽。
好了,先把文件建立好。
就是.h和.m啦。不能搞复杂了,因为这是第一个,so简单点。
#include <Foundation/NSObject.h> @interface Say: NSObject { } - (void) sayHello; - (void) sayHelloTo: (NSString *)name; @end
#import "say.h" #import <Foundation/Foundation.h> @implementation Say - (void) sayHello { NSLog(@"Hello World"); } - (void) sayHelloTo: (NSString *)name { NSLog(@"Hello World, %@", name); } @end
#import "say.h" #import <Foundation/Foundation.h> int main (void) { id speaker; NSString *name = @"GNUstep !"; NSAutoreleasePool *pool; pool = [NSAutoreleasePool new]; speaker = [[Say alloc] init]; [speaker sayHello]; [speaker sayHelloTo:name]; RELEASE(speaker); RELEASE(pool); }
GNUSTEP_MAKEFILES = /../../GNUstep/System/Library/Makefiles include $(GNUSTEP_MAKEFILES)/common.make # 编译生成的目标 TOOL_NAME = say # 头文件 say_HEARDER_FILES = say.h # 源文件 say_OBJC_FILES = main.m say.m # main_OBJC_FILES = $(mycar_HEARDER_FILES:.h=.m) main.m include $(GNUSTEP_MAKEFILES)/tool.make
看下截图: