Re: odd problem with NSMutableDictionary and initWithContentsOfFile
Re: odd problem with NSMutableDictionary and initWithContentsOfFile
- Subject: Re: odd problem with NSMutableDictionary and initWithContentsOfFile
- From: Andy Lee <email@hidden>
- Date: Thu, 29 May 2008 10:44:51 -0400
On May 29, 2008, at 9:41 AM, Leslie Smith wrote:
because within the documentation for initWithContentsOfFile it says
"Return Value: An initialized object—which might be different than
the original receiver ..."
and my original code assumes that the return value is the same object.
This is true of all init methods, by the way. You might want to
review the "Object Creation" docs here, in particular "Issues with
Initializers":
<http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/chapter_3_section_6.html
>
Make sure you understand the other thing that's been pointed out,
which is that init methods are not like other methods that you can
call any old time. Init methods are meant to be called exactly once,
immediately after alloc, and preferably in the same statement, as in
the example Jason Stephenson gave (to avoid errors of exactly this
kind).
Unfortunately there is no method called loadContentsOfFile: or
replaceAllWithContentsOfFile:. If there were, it would have served
your purpose.
--Andy
_______________________________________________
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