• 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
Outline View not retaining objects it uses. Why?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Outline View not retaining objects it uses. Why?


  • Subject: Outline View not retaining objects it uses. Why?
  • From: Paul Sargent <email@hidden>
  • Date: Sat, 19 Jul 2008 22:35:45 +0100

Hi all,

I've obviously not got the right mental model for something and I'm wondering why. It should be fairly obvious that this is quite early on in my Cocoa Career.

I've got an outline view that has a data source. The data source has routines that look like this:

-(id) outlineView:(NSOutlineView *) aView child:(NSInteger) anIndex ofItem:(id) anItem {
id aDataItem = [someArray objectAtIndex:anIndex];
return [NSDictionary dictionaryWithObjectsAndKeys:aDataItem, @"DataItem", extraInfo, @"ExtraInfo"];
}


-(id) outlineView:(NSOutlineView *) aView objectValueForTableColumn: (NSTableColumn *) aColumn byItem:(id) anItem {
id dataItem = [anItem objectForKey:@"DataItem"];
id extraInfo = [anItem objectForKey:@"ExtraInfo"];


	.....
}

This works fine the first time the view is populated, but when it's refreshed it just calls the second method with the pointers to the dictionaries I return first time round. Trouble is they've been autoreleased by now.

I know how to fix this, but I'm looking to understand.

Why, if the outline view is holding pointers to the objects I return from "outlineView:child:ofItem:", doesn't it retain them?
Why was I wrong to assume that an autoreleased object was sufficient?
Would the pointers it holds be strong or weak in a GC program?


Thanks

Paul
_______________________________________________

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


  • Follow-Ups:
    • Re: Outline View not retaining objects it uses. Why?
      • From: Quincey Morris <email@hidden>
  • Prev by Date: Re: Quick problem with arraycontroller
  • Next by Date: Re: More CALayer Questions
  • Previous by thread: Re: Drawer examples?
  • Next by thread: Re: Outline View not retaining objects it uses. Why?
  • Index(es):
    • Date
    • Thread