• 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: NSOutlineView: expanding an item retains it?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSOutlineView: expanding an item retains it?


  • Subject: Re: NSOutlineView: expanding an item retains it?
  • From: Charlton Wilbur <email@hidden>
  • Date: Mon, 24 Jan 2005 06:51:27 -0500


On Jan 24, 2005, at 6:08 AM, j o a r wrote:

But back to the topic of this thread: Why should an NSOutlineView retain an item provided by the data source? The data source must in my opinion be responsible for retaining all objects that it contains for as long as they are valid (ie. until reloadData are next called). So what would be the point of having the outline view also retaining them? To be able to use them after reloadData is called? Doesn't make much sense, right?

Imagine a multithreaded situation. Thread 1 handles the model, perhaps interacting with other computers. Thread 2 responds to user actions. It's entirely possible for Thread 1 to release an object, then for Thread 2 to do something with the outline View -- perhaps expanding the object that was just released -- then for Thread 1 to send the reloadData message.


What does it gain you if the outline view retains the items provided to it? You don't crash in that situation, or in similar ones where reloadData might not be called immediately. What does it cost you? Provided that both the outline view and your code are retain/release balanced, very little. I would expect that the NSOutlineView would release all items provided to it upon receipt of a reloadData message, for that matter; the point is to ensure that the objects do not vanish out from underneath it, to allow for graceful event handling in the event of a programmer not calling reloadData in a timely manner after releasing an object.

More importantly, it doesn't really matter if NSOutlineView retains the objects handed to it or not, so long as it behaves as it is documented. In the case of collection classes, by contrast, it's important to know that collections retain objects stored in them, and knowing that makes memory management easier. In the case of an NSOutlineView, it doesn't really matter, so long as Apple's code is retain/release balanced.

Charlton


-- Charlton Wilbur email@hidden email@hidden

_______________________________________________
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


  • Follow-Ups:
    • Re: NSOutlineView: expanding an item retains it?
      • From: j o a r <email@hidden>
References: 
 >NSOutlineView: expanding an item retains it? (From: Steve Mykytyn <email@hidden>)
 >Re: NSOutlineView: expanding an item retains it? (From: j o a r <email@hidden>)
 >Re: NSOutlineView: expanding an item retains it? (From: daniel <email@hidden>)
 >Re: NSOutlineView: expanding an item retains it? (From: Steven Kramer <email@hidden>)
 >Re: NSOutlineView: expanding an item retains it? (From: Charlton Wilbur <email@hidden>)
 >Re: NSOutlineView: expanding an item retains it? (From: j o a r <email@hidden>)

  • Prev by Date: Services and threads... Help!
  • Next by Date: NSAppleEventManager stops recieving events
  • Previous by thread: Re: NSOutlineView: expanding an item retains it?
  • Next by thread: Re: NSOutlineView: expanding an item retains it?
  • Index(es):
    • Date
    • Thread