[UIImageAsset retain]:发送给deallocated实例的消息

编程入门 行业动态 更新时间:2024-10-28 16:23:53
本文介绍了[UIImageAsset retain]:发送给deallocated实例的消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

一行

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

在后台线程的NSOperation中执行。 代码在这里打破消息:

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

[UIImageAsset retain]: message sent to deallocated instance

我的图像名称为 gradient-image in Images.xcassets 。 老实说,我甚至不知道其他相关信息是什么。

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.

推荐答案

直接来自 Apple的文档 c> UIImage imageNamed::

Straight from Apple's documentation on UIImage imageNamed::

您不能假设此方法是线程安全的。

You can not assume that this method is thread safe.

加载 UIImage 对象时,您必须在主线程上。你可以在任何线程上使用它们,但加载它们需要主线程。

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.

更多推荐

[UIImageAsset retain]:发送给deallocated实例的消息

本文发布于:2023-11-25 08:46:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1629093.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:实例   发送给   消息   UIImageAsset   retain

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!