• 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: Use of weak reference in non-circular reference situation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Use of weak reference in non-circular reference situation


  • Subject: Re: Use of weak reference in non-circular reference situation
  • From: James Bucanek <email@hidden>
  • Date: Wed, 31 May 2006 06:39:52 -0700

Eric wrote on Wednesday, May 31, 2006:
>An additional example would be:
>
>A window controller has instance variables holding different NSFont objects
>to use in the document, one instance variable for each font.  Each instance
>variable is retained as usual.  There is a separate instance variable
>"currentFont" that points to the currently active font.  In this case,
>should I retain the currentFont?  Or just assume it will be retained by the
>other instance variables?

I don't know if it's good Cocoa form or not, but I often do this too. I'll keep reference pointers to regularly used NSView* objects in my window that I don't bother retaining because I know the window hierarchy will retain them for the lifetime of the window. I usually note this in my interface:

    @private
        NSBox*      infoGroupView;      // view containing info fields (not retained)
        NSButton*   weekdayButtons[7];  // checkboxes for each day (not retained)
        ...

--
James Bucanek
 _______________________________________________
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: 
 >Use of weak reference in non-circular reference situation (From: Eric <email@hidden>)

  • Prev by Date: Re: Problem subclassing a NSCell in a NSTableView (solution)
  • Next by Date: Re: Drag & Drop iTunes tracks and Playlists
  • Previous by thread: Re: Use of weak reference in non-circular reference situation
  • Next by thread: Command-click table in background app
  • Index(es):
    • Date
    • Thread