wuqiang
wuqiang

Reputation: 644

Confusion about objc_getClass

In my Xcode project,I added the same framework for ios7 and ios8.I have renamed them to xxx-ios7.framework and xxx-ios8.framework. I want to use objc_getClass("someclass") to get the runtime class.But the two frameworks have the same class. How shoud I know which class I will get?

Upvotes: 1

Views: 549

Answers (1)

AhiyaHiya
AhiyaHiya

Reputation: 755

Although this may not be a great answer, you may want to use the same mechanism that Microsoft used in their MFC classes, which is defining a version number.

In essence, you would have a method, or methods like:

- (NSString*)classVersionAsString;
- (NSInterger)classVersionAsNumber;

which would return meaningful version information for you.

As noted in the comment above, you should be careful with having multiple frameworks with the same class names, since, the loader will pick the first class that matches a linker requirement by the dependent module or dependent application. When the modules are loaded, the class you get might not be what you expected.

Upvotes: 1

Related Questions