views:

44

answers:

1

Like Apple says, the dataFromPropertyList:format:errorDescription: method does not follow the object ownership policy. The method reference describes it. I have tried to search for "need to be released by the caller", but no useful results.

Here's a quote from the reference:

Special Considerations Unlike the normal memory management rules for Cocoa, strings returned in errorString need to be released by the caller.

I am almost pretty sure that this one is not the only case where this exception to the policy occurs.

+2  A: 

That’s a documentation bug, of sorts. It was true for Mac OS X 10.4 and earlier, but is not true for Mac programs that compile against the 10.5 SDK. I believe it is also not true for the iPhone, but haven’t tested it. (To test, generate an error, release the string, and see if you crash.)

The only other method I’m aware of with the same problem is +propertyListFromData:mutabilityOption:format:errorDescription:, which was fixed at the same time.

When the 10.5 SDK was released, I filed a bug (rdar://5563963) on the documentation, which had the warning you quote for both methods. The warning was removed, but appears to have been readded. I have requested that the bug be reopened.

Ahruman
To summarise: This behaviour is a bug in an older version of the framework. It's documented because Apple fixed it for 10.5. NOT that it is one of several deliberate exceptions to the memory management rules.
Mike Abdullah