开发者

Is there a trick to save time building in Xcode when there are thousands of images?

I've been reading an article about caching images in iPhone OS, and they pointed out this code snippet:

NSData *urlData = [NSData dataWithContentsOfURL:aURL];

When I do something like this, does the whole big image data get sucked into the memory? Or will the image data go into memory as soon as that urlData object is actually used? Right now I think they were wrong and this code snippet immediately brings the whole data into me开发者_开发知识库mory. My 10 Megapixel image causes the app to freeze and finally crash. If that snipped would not load the image into memory before usage, this should not happen, right?


Right, your code snippet slurps the file into memory (into one big malloc).

Your question is a bit unclear what you are trying to accomplish: Save build time? Prefetch images in your app? Cache images for reuse?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜