इस विषय में एक परिशिष्ट का थोड़ा सा:
'स्थिर रचनाकार' बनाने का एक और तरीका है I n Obj सी, एक __attribute
निर्देशों का उपयोग:
// prototype
void myStaticInitMethod(void);
__attribute__((constructor))
void myStaticInitMethod()
{
// code here will be called as soon as the binary is loaded into memory
// before any other code has a chance to call +initialize.
// useful for a situation where you have a struct that must be
// initialized before any calls are made to the class,
// as they would be used as parameters to the constructors.
// e.g.
myStructDef.myVariable1 = "some C string";
myStructDef.myFlag1 = TRUE;
// so when the user calls the code [MyClass createClassFromStruct:myStructDef],
// myStructDef is not junk values.
}
स्रोत
2012-01-05 14:39:28
"अगर ([स्वयं वर्ग] == [माईपैर क्लास क्लास])" '[स्वयं वर्ग] 'यहां अनावश्यक है। आप बस कह सकते हैं 'अगर (self == [MyParentClass क्लास]) ' – user102008
धन्यवाद! आपकी बोली ने मेरे प्रश्न का उत्तर दिया कि क्यों एक विशेष स्थिर प्रारंभकर्ता को दो बार बुलाया जा रहा था। –