I'm new to objective-C and cocoa also, I I don't know the answer to your
specific question about "self".  However, seems that one way to do it would
be to have the init of mySubObject have an initializer with argument, and
you would then create it something like this:

SubObject * mySubObject = [[SubObject alloc] initWithParent:self]

This save puting a variable set to 'self' inside MainObject.

Best,

John V.

On Tue, Oct 28, 2008 at 03:35:55AM +0100, john fogg wrote:
> Hi again!
> 
> I'm still plucking along and any help is still greatly appreciated!
> 
> Here is the deal: I create a subobject called "mySubObject" inside my
> main object "myMainObject". Now I want to access "myMainObject" from
> within "mySubObject".
> 
> I'm still not sure what the ideal way to do this would be but I have
> gotten it to work somehow. Inside "myMainObject" I create a property
> and point it to "self" so it stores a reference to "myMainObject".
> Inside "mySubObject" I cannot access this by writing
> 
>     [pointerToMainObject doMethod];
> 
> but it works when I write
> 
>     [self.pointerToMainObject doMethod];
> 
> Why? What difference does "self" make here?
> 
> I'm still trying to wrap my head around all this stuff so please bear
> with me here. :-)
> _______________________________________________
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> 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/velman%40cox.net
> 
> This email sent to [EMAIL PROTECTED]
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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