Skip navigation.
 
mlRe: odd problem with NSMutableDictionary and initWithContentsOfFile
FROM : Andy Lee
DATE : Thu May 29 16:44:51 2008

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

Related mailsAuthorDate
mlodd problem with NSMutableDictionary and initWithContentsOfFile Leslie Smith May 28, 09:58
mlRe: odd problem with NSMutableDictionary and initWithContentsOfFile Ken Ferry May 29, 10:39
mlRe: odd problem with NSMutableDictionary and initWithContentsOfFile Michael Vannorsdel May 29, 10:46
mlre: odd problem with NSMutableDictionary and initWithContentsOfFile Leslie Smith May 29, 15:41
mlRe: odd problem with NSMutableDictionary and initWithContentsOfFile Jason Stephenson May 29, 15:50
mlRe: odd problem with NSMutableDictionary and initWithContentsOfFile Andy Lee May 29, 16:44
mlRe: odd problem with NSMutableDictionary and initWithContentsOfFile Jens Alfke May 29, 16:47
mlRe: odd problem with NSMutableDictionary and initWithContentsOfFile Jason Coco May 29, 17:44