My app displays several images on several pages.
Since the app displays one page per time, I would like to optimize the
memory management at loading and displaying the images.
I thought to save my document as filePackage, put the image files within the
package and use the lazy

    image = [[NSImage alloc] initByReferencingFile:path];

to reference all the images when opening a document. So, I thought, the
images get really loaded and displayed at the time I select a given page,
and discarded (in the cache) when I change page. Does it really work that
way?

Second question. In case the user imports a new image, I presume I should
immediately copy the image file within the filePackage then call
initByReferencingFile. Should I use

    imgFileWrap = [[NSFileWrapper alloc] initWithURL:url options:
NSFileWrapperReadingWithoutMapping error:&err];
    [documentFileWrapper addFileWrapper: imgFileWrap];

 or should I simply copy the file image within the filePackage with the
following?

    [[NSFileManager defaultManager] copyItemAtPath:src toPath:dst
error:nil];


Regards
-- Leonardo


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to