오전 11:29 2008-10-07
Obj-C 정적 멤버 변수
조경민 bro@shinbiro.com
=========================================================


애플의 ObjC.pdf는 다음과 같이 써있다.


There is, however, no "class variable" counterpart to an instance variable.
그러나 instance variable의 쌍이되는 class variable이라는 건 없다.


그러면서 다음을 추천하고 있다.


static MyClass *MCLSSharedInstance;
@implementation MyClass
+ (MyClass *)sharedInstance
{
// check for existence of shared instance
// create if necessary
return MCLSSharedInstance;
}
// implementation continues


의문점:
http://lists.apple.com/archives/Objc-language/2003/Dec/msg00069.html
를 보면 @classVariables, @static, @cvar를 사용하여 class variable을 표현하고 있다. 이건 뭘까? --;
=> 어쨋든 iPhone에서는 이딴거 없다..



@interface PGPlanet : NSObject {
// Instance vars
@protected
NSString *name;
NSMutableArray *satellites;
int uniqueID;


// Class vars
@classVariables
@private
int planetCount;
}


또는


@interface Foo : Bar {
@protected
NSString *blah;
NSString *blahBlah;
@static int nextUID;


@private
@static NSMutableDictionary *instanceCache;
}


또는


@interface Foo : Bar {
@ivar { << with this being optional and any root items are considered instance vars
@protected
...


@private
...
}


@cvar {
@protected
...


@private
...
}
}

'KB > iphone/mac' 카테고리의 다른 글

[iPhoneSDK] How to make first Instance  (0) 2008.10.08
[iPhoneSDK] Using UIImageView  (0) 2008.10.08
[iPhoneSDK] Using TabBar  (0) 2008.10.07
[iPhoneSDK] MyViewController 추가하기  (0) 2008.10.07
[iPhone SDK] ViewController 관련..  (0) 2008.10.02

+ Recent posts