lundi 30 janvier 2017

Objective C reflection for C-type vars

I have few extern variables declared in @interface block of my .h file. They are assigned in .m file. In one method of my @interface (preferable class method) I want to enumerate over these variables via reflection, but I have no any idea is it possible at all, and how is yes ? Example of my code:

Consts.h

extern NSString *MyConst1;
extern NSString *MyConst2;

Consts.m

NSString *MyConst1 = nil;
NSString *MyConst2 = nil;

+ (void)load {
  MyConst1 = ...;
  MyConst2 = ...;
}

+ (void)someMethod {
  // i could use class_copyIvarList for objective c properties/ivars, 
  // but is it possible to get that MyConts1 and MyConst2 via reflection ? 
  // I understand, that C have different namespace,
  // and I have no experience with it. 
}





Aucun commentaire:

Enregistrer un commentaire