Re: primitiveValueForKey Memory Management
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