• 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: Object References in Obj-C
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Object References in Obj-C


  • Subject: Re: Object References in Obj-C
  • From: Charilaos Skiadas <email@hidden>
  • Date: Mon, 23 May 2005 10:03:48 -0500


On May 23, 2005, at 9:49 AM, Iain Delaney wrote:

Hi all,
Here's my situation: My AppController has a dictionary of objects. One of these objects creates a worker object that may need to get information from another object in the dictionary. Do Obj-C objects know anything about the object that instantiated them? Or should I pass a pointer to the parent or AppController around?

The object that instantiated them might not be around for long, so it would be a bit dangerous for the objects to know about it. You could pass a pointer to the appController, if that's really what you need, but unless you retain the controller, there is no guarantee it is going to be around, and you should absolutely NOT retain the controller, because you'll probably get a retain cycle, that is if the controller has retained the object. But there might be other ways of accomplishing what you want to do, maybe more obj-C-friendly. So the question is, what are you trying to accomplish?

Right now, I've got a member variable of type (AppController *) MyApp that I set with self from inside the AppController class, but I'm not that comfortable with that. Is this the right way to do things, or is there a better way?

Iain

<x-tad-smaller>Haris</x-tad-smaller>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Object References in Obj-C (From: Iain Delaney <email@hidden>)

  • Prev by Date: Re: Manual KVO quirks with NSDocument and NSWindowController
  • Next by Date: Re: Object References in Obj-C
  • Previous by thread: Object References in Obj-C
  • Next by thread: Re: Object References in Obj-C
  • Index(es):
    • Date
    • Thread