Thread safety of UIImage

后端 未结 6 981
一整个雨季
一整个雨季 2020-12-31 19:43

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

6条回答
  •  余生分开走
    2020-12-31 20:18

    Directly from Apple's documentation for UIImage

    Image objects are immutable, so you cannot change their properties after creation. This means that you generally specify an image’s properties at initialization time or rely on the image’s metadata to provide the property value. It also means that image objects are themselves safe to use from any thread. The way you change the properties of an existing image object is to use one of the available convenience methods to create a copy of the image but with the custom value you want.

    (Emphasis mine)

    So at least in the current version of the SDK as of May 13, 2014, "image objects are themselves safe to use from any thread."

提交回复
热议问题