The role of -supportsWeakPointers

点点圈 提交于 2019-11-30 02:04:18
Joshua Weinberg
  1. Consider the case of a class with both a "shared" or "default" instance and other instances (e.g. NSFileManager). Your shared instance likely has different weak pointer behavior from the other allocatable instances. There are times where different instances may want different weak pointer behavior. That having been said, if this is the case something's probably Not Quite Right.

    (Answer 1. was originally written by Chris Parker. I’m adding it to Joshua’s answer so that the accepted answer is complete.)

  2. In your sample changing supportsWeakPointers to allowsWeakReference as defined in NSObject.h causes things to behave as one would expect. It's marked as NS_DEPRECATED but it doesn't look like there is an alternative in the SDK yet.

  1. Consider the case of a class with both a "shared" or "default" instance and other instances (e.g. NSFileManager). Your shared instance likely has different weak pointer behavior from the other allocatable instances. There are times where different instances may want different weak pointer behavior. That having been said, if this is the case something's probably Not Quite Right.

  2. Dunno. :)

  3. Sounds like it might be a bug; I'd have to see a sample project to have a better idea of what's going on.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!