Thread-safe UIKit methods(线程安全的 UIKit 方法)
问题描述
我正在尝试找出在 iOS 4.0 上的 UIKit 中哪些方法(名称!)成为线程安全的.
I'm trying to find out exactly what methods (names!) became thread safe in UIKit on iOS 4.0.
我搜索了 Apple 的文档,但收效甚微.例如,使用 imageNamed: 创建的 UIImage 在其他线程上使用是不安全的(它偶尔会从主线程中丢弃它的 CGImage),而 imageWithCGImage代码> 可能是(?).此外,我还看到声称 UIColor 可以安全地用于主线程以外的线程.
I've searched through Apple's docs with little success. For instance a UIImage created with imageNamed: is not safe to use on other threads (it will occasionally jettison its CGImage from the main thread), while imageWithCGImage might be(?). Also, I've seen claims that UIColor is safe to use on threads other than the main thread.
对于哪些方法安全哪些不安全,是否有明确的指南?
Is there some definite guide as to which methods are safe which ones isn't?
有趣的是在单独的线程上使用的 UIKit 类很有趣,例如 UIImage、UIColor 等.
What's interesting is UIKit classes that is interesting to use on separate threads, such as UIImage, UIColor etc.
推荐答案
来自苹果的文档:
注意:在大多数情况下,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
UIResponderor that involve manipulating your application’s user interface in any way.
因此,您真的不应该在后台线程上与 UIKit 中的任何内容进行交互.
Therefore, you really shouldn't be interacting with anything in UIKit on a background thread.
这篇关于线程安全的 UIKit 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:线程安全的 UIKit 方法
基础教程推荐
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
