Making deep copy of UIImage

前端 未结 6 1753
梦谈多话
梦谈多话 2020-12-16 15:44

My class contains an UIImage property which I want to enforce as a \'copy\' property by any external clients accessing it. But, when I try to do a copy in my custom setter,

6条回答
  •  误落风尘
    2020-12-16 16:19

    Why do you need copy semantics? The UIImage is immutable, so there's no benefit to setting a copy policy. You just need a copy policy if there's the risk that someone else could modify the image on you. Since the UIImage is immutable, there's no risk of that happening, so a retain property is fine.

    If you explain a bit more what you're trying to do, it might be that there's some other way of achieving it.

提交回复
热议问题