Object-C 문법 기초

2852 단어 object-c
Object-C
 C          ,
               ,
      (           Java C++            ,
      C     ).

Object-C          ,           .
   Java   C++,              :
    ctx.method(5);
  OC        :
    [ctx method:5];

oc           C++        child : parent

키워드
oc      @    

oc class
oc C++          
            .m   
C++     :
class test {
public:
    void call(int n);

private:
    int mVal;
};

@interface   @end  
oc:
@interface test : NSObject {
@private //     
    int mVal;
}

-(void) call: (int)n; //   call
@end

@implementation   @end  
oc:
@implemnetation test

-(void) call: (int) n
{
    NSLog(@"hello object-c");
}
@end

self & super
C++  this        

oc self         super     

구조 와 분석
C++               
class test {
public:
    test() {}
    ~test() {}
};

 oc                
-(id) init
{
    if (self = [super init])
    {

    }
    return self;
}

-(void) dealloc
{
    [super dealloc];
}

방법.
oc    .m   
-               +        
call    
n n2       
-(void) call: (int) n: (int) n2
{

}

좋은 웹페이지 즐겨찾기