3

Possible Duplicate:
What is the best way to solve an Objective-C namespace collision?

I was using 2 open source projects in an application with different use --- the issue was that both project had same class name with different implementations.

As per my understanding objective C don't have namespace option to handle scope --- as of now I am renaming the one of the class and its usage to make it work in my project.

Is there any alternative solution then renaming? I feel like objective C is missing namespace.

Community
  • 1
  • 1
Girish Kolari
  • 2,515
  • 2
  • 24
  • 34
  • They do use it, eg. etc.. Not sure how to implement it though :S. – Sailesh Apr 09 '11 at 09:36
  • 1
    @Sailesh This has nothing to do with namespaces. It's just organization of files. – Eiko Apr 09 '11 at 11:14
  • 1
    it might be instructive to share the class name that caused the collision, as well as the names of the two frameworks. – jlehr Apr 09 '11 at 19:29

1 Answers1

6

Renaming is the correct way. There is a reason why Apple recommends to prefix your classes with some uppercase letters. This should prevent exactly this situation. Same for method names in class extension, or "private" methods.

Eiko
  • 25,601
  • 15
  • 56
  • 71
  • 1
    Fortunately if you add one library and use Xcode's refactoring to rename the offending classes you're unlikely to make a mistake. Then, obviously, add the other library. – Matthew Frederick Apr 09 '11 at 10:19
  • rename is the way that is what I am using now --- hard path for rename in my case is - if I have to use latest version of open source in some other day I have to rename it again ... this is why I am looking for a better solution then rename. – Girish Kolari Apr 09 '11 at 10:38
  • 2
    Convince the open source project to prefix their classes, you are likely not the only one who runs into this problem - now or later. You might get away with #define magic to rename the files in a small framework with minimal changes. – Eiko Apr 09 '11 at 11:13
  • Since any decent Objective-C framework already uses a reasonably well thought-out prefix, name collisions are rare. Not impossible, though, unfortunately, as you've already discovered. – jlehr Apr 09 '11 at 19:15
  • @jlehr: Did I miss the names of the frameworks here? – Eiko Apr 09 '11 at 19:23
  • @Eiko: Sorry, I wasn't responding to your comment, just making a general observation (should have made that clear though). I don't believe the OP shared the name of the class or of the frameworks for that matter. – jlehr Apr 09 '11 at 19:28