Using the sample below,  how do I get the instance of the class in which I am 
contained WITHOUT passing it as a parameter or using hacky sizeof tricks in the 
method Foo:method?  Thanks people!  If this is not the correct alias for this 
type of question, apologizes in advance.


@interface Foo : NSObject
{
        id containerClass;
}
-(void) method;
@end

@implementation Foo

-(void) method
{
        // set containerClass member to point to the instance in which I am 
contained
        // (i.e. the pointer to the instance of Bar.
        // 'self' refers to an instance of Foo
}
@end

**************************************************************************************

@interface Bar : NSObject
{
        Foo * f; // contains a Foo
}
@end

@implementation Bar
- (id) init
{
        ...
        
        // Call 'method' on object 'f' of type Foo
        [f method];

        ...
}
@end



-tony


_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to