Re: Odd crash only when Toast running
Re: Odd crash only when Toast running
- Subject: Re: Odd crash only when Toast running
- From: Ken Ferry <email@hidden>
- Date: Tue, 2 Jun 2009 11:15:39 -0700
On Tue, Jun 2, 2009 at 7:57 AM, Shawn Erickson <email@hidden> wrote:
> On Tue, Jun 2, 2009 at 12:12 AM, Graham Cox <email@hidden>
> wrote:
> >
> > On 02/06/2009, at 4:23 PM, Trygve Inda wrote:
>
> >> The file that this image comes from will be deleted later on, but once
> >> initWithContentsOfFile is called, I assume it no longer needs the file,
> >> right?
>
> No it might still need the file. NSImage is often lazy about what it
> does so as to not waste resources until they are needed. Can you
> outline what you are doing with the file after you create the NSImage
> instance? Are you writing to it again, etc.?
This is the difference between -initByReferencingURL: and
-initWithContentsOfURL:.
The "contents" methods non-lazily suck the data in from disk and
disassociate from the file.
The "referencing" methods, on the other hand, treat the in-memory
representation as a cache for the file on disk. When you use this method,
you promise that the file on disk is not going anywhere or changing. It's
easy to make this promise for files that are in your app's bundle and are
used for its UI. +[NSImage imageNamed:] uses -initByReferencingURL:.
-initByReferencingURL: does no IO.
-Ken
Cocoa Frameworks
_______________________________________________
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