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
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 mails | Author | Date |
|---|---|---|
| Leslie Smith | May 28, 09:58 | |
| Ken Ferry | May 29, 10:39 | |
| Michael Vannorsdel | May 29, 10:46 | |
| Leslie Smith | May 29, 15:41 | |
| Jason Stephenson | May 29, 15:50 | |
| Andy Lee | May 29, 16:44 | |
| Jens Alfke | May 29, 16:47 | |
| Jason Coco | May 29, 17:44 |






Cocoa mail archive

