Still.Tony
Still.Tony

Reputation: 1434

Selectively loading classes in Objective-C

I have modules but no source code from two different people which both include the same class. Is there any way to selectively load classes out of the modules so that the duplicated class doesn't collide?

Yes I am aware of this alternate solution which suggests loading and unloading and would rather do it by selectively loading classes and being done with it. What is the best way to solve an Objective-C namespace collision?

Upvotes: 4

Views: 172

Answers (1)

Joel Fischer
Joel Fischer

Reputation: 6597

If the code is written into a .framework, you could possibly load using something like #import <myFramework/MFMyCode.h>. There's no way to selectively load a class in objective-c for iDevices, if you're on the Mac, you can use the method linked in your question.

I ran across this problem where I wanted to conditionally load a class from a project if that project existed, and to not load it if it did not. Unfortunately, there's no real way to resolve this problem since imports are all done at compile time.

Upvotes: 1

Related Questions