• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: ObjC question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ObjC question


  • Subject: Re: ObjC question
  • From: "Clark S. Cox III" <email@hidden>
  • Date: Sat, 10 Apr 2010 16:16:59 -0700

You cannot. You will have a pointer of some kind in your Foo class that points to the current "container".

Sent from my iPad

On Apr 10, 2010, at 14:38, Tony Romano <email@hidden> wrote:

> 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@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
_______________________________________________

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

References: 
 >ObjC question (From: Tony Romano <email@hidden>)

  • Prev by Date: Re: ObjC question
  • Next by Date: Cant read second table from same sqlite database iphone
  • Previous by thread: Re: ObjC question
  • Next by thread: Cant read second table from same sqlite database iphone
  • Index(es):
    • Date
    • Thread