(+)와 (-)함수의 차이는?

2012. 3. 26. 17:28Language/iPhone

반응형

 



//

//  main.m

//  demoClassInstance

//

//  Created by SDS107 on 12. 3. 26..

//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.

//


#import <Foundation/Foundation.h>


@interface DemoInstance : NSObject

+(void)ClassMethod;

-(void)instanceMethod;

@end


@implementation DemoInstance

+(void)ClassMethod

{

    NSLog(@"클래스에서 직접 호출");

}

-(void)instanceMethod

{

    NSLog(@"인스턴스에서 직접 호출");

}

@end



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

{

    

    [DemoInstance ClassMethod];    // 객체를 생성하지 않아도 호출 있다

    

    DemoInstance *demo = [DemoInstance new];

    [demo instanceMethod];   // 객체를 만들고 뒤에 호출 한다. 대부분의 방식이다.

    

    return 0;

}


반응형

'Language > iPhone' 카테고리의 다른 글

제3장. Objective C[오전+오후]  (0) 2012.03.28
제2장. Objective C (하편)  (0) 2012.03.27
제 2장. Objective C  (0) 2012.03.27
제 1장. Objective C  (0) 2012.03.26
iPhone 시작!  (0) 2012.02.16