Re: simulating nested classes in objective-c
Re: simulating nested classes in objective-c
- Subject: Re: simulating nested classes in objective-c
- From: Alastair Houghton <email@hidden>
- Date: Tue, 21 Apr 2009 11:29:06 +0100
On 19 Apr 2009, at 23:22, Aroon Pahwa wrote:
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.
Don't forget that you can use the preprocessor. For instance you
might do something like
#define P(x) CURRENTCLASS ## x
#define CURRENTCLASS SomeContainerClass
...
then the "nested" classes' names can be written
P(ResultInfo)
and when you want to define the other class simply
#undef CURRENTCLASS
#define CURRENTCLASS SomeOtherContainerClass
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.
Not sure my solution really fulfils all of the above, but it's
certainly shorter.
I will just add that it's possible that the problem you're having here
is being caused by your having too many similar classes; maybe some of
your custom classes could be replaced by e.g. NSDictionary instead?
Kind regards,
Alastair.
--
http://alastairs-place.net
_______________________________________________
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