UIImage的线程安全性 [英] Thread safety of UIImage

查看:339
本文介绍了UIImage的线程安全性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道Apple官方建议仅在主线程中使用UIKit。但是,我也听说过自iOS 4.0以来UIImage是线程安全的。我找不到支持此声明的任何文档。

I know that Apple officially recommends UIKit to be used in the main thread only. However, I've also heard claims that UIImage is thread-safe since iOS 4.0. I cannot find any documentation backing this claim.

有没有人有任何信息支持这项索赔?作为用于存储数据和解码图像数据的类,如果设计得好,UIImage应该是线程安全的。

Does anyone have any information to support this claim? As a class used to store data and decode image data, UIImage should be thread-safe if well designed.

推荐答案

这是真的Apple建议在主线程上使用UIKIt中的元素:

It is true that apple recommends using elements from the UIKIt on the main thread:


注意:大多数情况下,UIKit类只能用于
应用程序的主要线程。对于从UIResponder派生的类
或者涉及以任何方式操纵
应用程序的用户界面的情况尤其如此。

Note: For the most part, UIKit classes should be used only from an application’s main thread. This is particularly true for classes derived from UIResponder or that involve manipulating your application’s user interface in any way.

因为UIImage不是从UIResponder派生的,所以你实际上并没有在界面/屏幕上显示它。然后在另一个线程上使用UIImages进行操作应该是安全的。

Since UIImage isn't derived from UIResponder, and you do not actually display it on the interface/screen. Then doing operations with UIImages on another thread should be safe.

然而,根据我的经验,我还没有看到任何关于它的官方文档。

This is however based on my experience, I haven't seen any official documentation about it.

这篇关于UIImage的线程安全性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆