Re: NSPropertyListSerialization violates object ownership rules?
Re: NSPropertyListSerialization violates object ownership rules?
- Subject: Re: NSPropertyListSerialization violates object ownership rules?
- From: Ali Ozer <email@hidden>
- Date: Sun, 6 Oct 2002 16:59:23 -0700
The documentation for NSPropertyListSerialization
dataFromPropertyList:format:errorDescription: says
+ (NSData *)dataFromPropertyList:(id)plist
format:(NSPropertyListFormat)format errorDescription:(NSString
**)errorString
Returns an NSData object in the property list format specified by
plist or nil if plist does not represent a valid property list. plist
must be a kind of NSData, NSString, NSNumber, NSDate, NSArray, or
NSDictionary. Container objects must also contain only these kinds of
objects. On return, if the conversion is successful, errorString is
nil. If the conversion fails, errorString points to a string
describing the nature of the error. If you receive a string, you must
release it. Possible values for format are described in "Constants".
Is this correct? (That I must release the error string? That is the
current implementation seems to agree with the documentation, but
seems counter to the usual memory management rules.)
Isn't this counter to the usual Cocoa memory management "contract"
whereby if I didn't alloc, copy, or retain and object, I don't have to
release it? NSPropertyListSerialization is the one who created the
error string, but the documentation is passing the responsibility to
me to release it.
Jim,
You are right; the documentation (and it seems that the implementation
too) are wrong. There are other examples of this which do behave the
other way --- that is, do not require you to release the by-ref return.
As the memory management rules would imply. For now you should do the
right thing and release the return value, and please submit a bug.
Ali
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.