simulating nested classes in objective-c
simulating nested classes in objective-c
- Subject: simulating nested classes in objective-c
- From: Aroon Pahwa <email@hidden>
- Date: Sun, 19 Apr 2009 15:22:55 -0700
- Acceptlanguage: en-US
- Thread-topic: simulating nested classes in objective-c
I'm working on a project that involves translating C# code to Objective-C (so I never have to write network protocol definitions again!).
I've run into an issue: C# (and Java) both have nested classes which is the ability to define a new class inside of an existing class. This is a nice feature for breaking up functionality within a class, reducing namespace pollution and generally organizing data structures. The problem, of course, is that Objective-C doesn't have nested classes.
Luckily I don't actually need to translate the C# nested classes to something of similar functionality, I just need to solve the problem of naming collisions. For instance, if the C# code has two classes that both define a nested class named ResultInfo then I end up with a collision.
My first soltion was to prepend the name of the containing class to the name of the nested class so in the previous example I would end up with SomeContainerClass_ResultInfo and SomeOtherContainerClass_ResultInfo. My issue with this is that the names are waaaay too long.
I'm wondering if anyone has had to deal with this issue before and has any ideas of what I can do to keep the names short, not kill the usefulness of Code Sense in XCode, and come at least close to gauranteeing no naming collisions between these translated nested classes.
I've read a ton of docs about the porting of and bridges between Java code and Objective-C but they all seem to gloss over the issue of nested classes...
Thanks in advance!
Aroon
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden