技术库 > Object-C

在Terminal命令行模式下运行Objective-C

技术库:tec.5lulu.com

from:tec.5lulu.com

File: xxd.h 
#include <Foundation/Foundation.h>
@interface Xxd: NSObject
{
}
- (void) xxdSayHelloTo: (NSString *)name;
@end

File: xxd.m 

#include <Foundation/Foundation.h>
#include "xxd.h"
@implementation Xxd
- (void) xxdSayHelloTo: (NSString *)name
{
NSLog(@"Hello World, %@", name);
}
@end

File: main.m 

#include <Foundation/Foundation.h>
#include “xxd.h”
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
id speaker;   
NSString *name = @"test";   
xxd = [[Xxd alloc] init];   
[xxd xxdSayHelloTo:name];   
[xxd release];   
[pool drain];   
return 0;   
} 

运行  

$ gcc -framework Foundation main.m xxd.m -o xxd 

$ ./xxd

2014-06-07 09:28:40.815 test[1459:707] Hello World, test

在Terminal命令行模式下运行Objective-C,by 5lulu.com

在Terminal命令行模式下运行Objective-C


标签: 命令行 const gcc int char本文链接 http://tec.5lulu.com/detail/108asn4wm61s38s78.html

我来评分 :6.1
0

转载注明:转自5lulu技术库

本站遵循:署名-非商业性使用-禁止演绎 3.0 共享协议

www.5lulu.com