4

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?

Community
  • 1
  • 1
Still.Tony
  • 1,437
  • 12
  • 35
  • If those classes collide, find a different library, because it indicates a lack of planning and foresight on somebody's part. – CodaFi Oct 08 '13 at 18:30
  • 1
    As I recall, NSClassFromString can be "context sensitive" and fetch different classes depending on where (which load module) it's executed. But it's far from a "documented feature" and should not be used for anything other than parlor tricks. – Hot Licks Oct 08 '13 at 21:14
  • 1
    http://stackoverflow.com/a/19317241/2043621 – AppFzx Oct 11 '13 at 17:30

1 Answers1

1

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.

Joel Fischer
  • 6,521
  • 5
  • 35
  • 46