Re: Executing methods in one class from within another
Re: Executing methods in one class from within another
- Subject: Re: Executing methods in one class from within another
- From: Richard <email@hidden>
- Date: Wed, 12 Jun 2002 12:51:10 +1000
- Organization: Faraday R&D
Alexander Reichstadt wrote:
>
That's kind of tricky with giving examples in terms of code. Let me try
>
to explain, it's a general condition that I am certain is trivial to
>
many of you, think basic, chances are I missed some piece at the lower
>
level
>
>
I have some app, document based or not is not of concern, I think. In my
>
app I have two NSObject subclasses, myClassA, myClassB. myClassA has an
>
accessor, let's say for some NSString -(NSString *)myString. Now, if I
>
need to retrieve the value that is currently in this string, but need to
>
do so in myClassB, I don't know how to go about this, if instances of
>
myClassA and myClassB were created at the same level, so that I could
>
not say #import myClassA in myClassB and #import myClassB in myClassA,
>
which, of course, gives me a compiler error.
This particular problem can be solved using the
@class ClassA;
@interface ClassB: NSObject
{
ClassA* mA;
}
forward declaration,
which is pretty similar to the way c++ handles such problems.
>
I can either do the one or
>
the other, but not both. myClassA doesn't, at this stage, 'possess' an
>
instance of myClassB, and neither vice versa, so I have problems having
>
the two accessing values from each other if I do not have some central
>
switchboard widget that allows me to get hold of one from within the
>
other.
So once the compilation problem is solved you can have an instance
of one class stored in another, either when the class is init-ed
or via a setter function.
>
>
>
Is that clearer now?
>
>
Thank you
>
Alex
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.