dealloc on Background Thread

前端 未结 4 1766
北荒
北荒 2021-01-18 22:55

Is it an error to call dealloc on a UIViewController from a background thread? It seems that UITextView (can?) eventually call _

4条回答
  •  独厮守ぢ
    2021-01-18 23:16

    It is an error to call dealloc on anything at any time. You should only ever call release.

    You should not access any UI related instances from a background thread. This includes using getter methods because they may modify things internally. However, retain and release are thread safe for any object at any time, as long as the normal rules for retain and release are followed. UI related instances include any object that is referenced by an active UIView or UIViewController.

    performSelectorOnMainThread does not do anything more than retain an object until it gets to the main thread. It is safe to call on any UI related object.

提交回复
热议问题