Answer the question
In order to leave comments, you need to log in
How to make classes unique for each static library in ObjectiveC?
There are two static libraries: lib1.a and lib2.a . Each library has its own implementation of class A.
The problem is that when executing, if the class from the lib1 library was used first, the same class is also used in the lib2 library.
How can I make each library use its own implementation of class A?
Answer the question
In order to leave comments, you need to log in
I'm not sure if this will work, you need to try
1) Get the Class from the desired one
or something like this (the code was written right here, focusing on )
static inline Class getClassFromLib1(){
int numberOfClasses = objc_getClassList(NULL, 0);
Class *classes = calloc(sizeof(Class), numberOfClasses);
Class retClass = Nil;
numberOfClasses = objc_getClassList(classes, numberOfClasses);
for (int i = 0; i < numberOfClasses; ++i) {
Class c = classes[i];
if (([NSBundle bundleForClass:c] ==/*нужная либа*/)&&(/*проверка на нужный класс*/)) {
retClass = c;
break;
}
}
free(classes);
return retClass;
}
Class a = getClassFromLib1();
id objectClass1 = [[a alloc] init];
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question