'method'에 해당되는 글 1건

  1. 2008.10.22 Objective C Method
2008.10.22 21:38

간단하게 Method에 메시지를 전달 하는것과, 인자를 가진 Method를 선언하고 정의한것을 예 로든 소스이다.


#import <Cocoa/Cocoa.h>

#import <stdio.h>


@interface ClassName : NSObject

{

@public

int iInstanceVariable;

float fInstanceVariable;

}

-(void)display;

-(void)setVariable: (int)iIVariable;

-(void)setVariable: (int)iIVariable fVariable: (float)fIVariable;

@end


@implementation ClassName

-(void)display

{

printf("%d %f\n", iInstanceVariable, fInstanceVariable);

}

-(void)setVariable: (int)iIvariable

{

iInstanceVariable = iIvariable;

}

-(void)setVariable: (int)iIVariable fVariable: (float)fIVariable;

{

iInstanceVariable = iIVariable;

fInstanceVariable = fIVariable;

}

@end


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

{

id clsN;

clsN = [ClassName new];

[clsN setVariable:10 fVariable:10.5];

[clsN display];

[clsN setVariable:20];

[clsN display];

return 0;

}


신고
Posted by 우엉 여왕님!! ghostkyow

티스토리 툴바