본문 바로가기

C.O.M.P.U.T.E.R/O.b.j.e.c.t.i.v.e.-.C

[0] |Objective-C| C언어와 Objective-C언어와의 차이점

#import <Cocoa/Cocoa.h>

@interface MyClass : NSObject

{

    // 멤버 변수

    int x, y;

}

 

// 멤버 메소드 추가부분

// C언어 -> void method();

-(void)method;

@end

 

// 멤버 메소드에 대한 사양

@implementation MyClass

-(void)method

{

    NSLog(@"MyClass method\n");

}

 

@end

 

int main(int argc, char *argv[])

{

    MyClass *cls;   // instance 인스턴스


   
// C언어 -> cls = new MyClass;

    cls = [MyClass alloc];


   
// C++언어 -> cls.method();

    [cls method];

   

    
/*    

    pritnf("Hello Apple\n");

    char c = 'A';

    int i = 365;

    double d = 3.14;

    NSLog(@"Hello Apple %c, %d, %lf\n", c, i, d);

    scanf("%d", &i);

    */

    // Next Step = NS

    return NSApplicationMain(argc, (const char **)argv);

}


오늘부터 3일간 Objective-C를 마스터 해야 하는데... C언어와의 차이점은 그다지 없어 보이네요. @가 포함 되는 것 정도로 밖에 안보이네요. NSLog라던지 새로운 것들이 많은데 아이폰 애플리케이션은 회사 들어가서도 부업으로 먹고 살 수 있을 정도로 배웠으면 좋겠네요. 팀과 다른 개인이 좋은 점도 있기 때문에...