[UIImageAsset retain]: message sent to deallocated instance

好久不见. 提交于 2020-01-07 06:47:19

问题


A line

UIImage *tempImage = [UIImage imageNamed:@"gradient-image"];

gets executed inside an NSOperation, on the background thread. The code breaks here with the message:

[UIImageAsset retain]: message sent to deallocated instance

I have the image by the name gradient-image in Images.xcassets. Honestly, I don't even know what other info would be relevant.

This happens on rare occasions, I cannot reproduce it consistently. I've googled a bit, but not much results. So, I decided to create a question here on SO.


回答1:


Straight from Apple's documentation on UIImage imageNamed::

You can not assume that this method is thread safe.

You must be on the main thread when loading UIImage objects. You can be on any thread when using them, but loading them requires the main thread.



来源:https://stackoverflow.com/questions/28544201/uiimageasset-retain-message-sent-to-deallocated-instance

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!