• 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: primitiveValueForKey Memory Management
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: primitiveValueForKey Memory Management


  • Subject: Re: primitiveValueForKey Memory Management
  • From: Chris Hanson <email@hidden>
  • Date: Sun, 29 May 2005 11:27:20 -0700

On May 29, 2005, at 4:55 AM, Phil Larson wrote:
What is the reference count state of objects returned from primitiveValueForKey?

More important than the reference count is the ownership of objects returned from -primitiveValueForKey:.


They're owned by the NSManagedObject in question. You shouldn't need to change the generated templates to do [tmpValue copy] or [[tmpValue retain] autorelease] or anything like that, so long as your managed objects themselves are properly retained.

Of course, you may want to copy the result of invoking an accessor (e.g. [[myObject name] copy]) if you need to use it "detached" from the object that owns it.

However, by the time the NSOutlineView calls the last method, it seems the name string has become mangled or deallocated. The program will quit with an EXC_BAD_ACCESS when I expand the arrow next to "TopLevel".

One thing to note about NSOutlineView is that it does not retain the items passed to it by its datasource. Its datasource must own the items.


  -- Chris

_______________________________________________
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: primitiveValueForKey Memory Management
      • From: Phil Larson <email@hidden>
References: 
 >primitiveValueForKey Memory Management (From: Phil Larson <email@hidden>)

  • Prev by Date: Re: Monitoring system time
  • Next by Date: Re: Wake from Sleep
  • Previous by thread: Re: primitiveValueForKey Memory Management
  • Next by thread: Re: primitiveValueForKey Memory Management
  • Index(es):
    • Date
    • Thread