美文网首页
Cannot create __weak reference i

Cannot create __weak reference i

作者: petter102 | 来源:发表于2018-04-04 01:34 被阅读63次

    更新Xcode 9.3后编译可能会出现这个错:cannot create __weak reference in file using manual reference counting
    解决方法:

    1.可以设置build setting -> Apple LLVM9.1 - Language - Objective C -> Weak References in Manual Retain Release YES

    image.png

    2.用 __unsafe_unretained 代替 __weak,但是如果用 __unsafe_unretained请注意下面的问题。
    __unsafe_unretained specifies a reference that does not keep the referenced object alive and is not set to nil when there are no strong references to the object. If the object it references is deallocated, the pointer is left dangling.

    Answer from Apple:
    This issue behaves as intended based on the following: We are in the process of implementing weak references in all Objective-C language modes. Since “__weak” has historically been ignored in non-ARC (and non-GC) language modes, we’ve added this error to point out places where the semantics will change in the future. Please update your bug report to let us know if this is still an issue for you.

    原文链接:http://keepmovingxin.com/archives/36

    相关文章

      网友评论

          本文标题:Cannot create __weak reference i

          本文链接:https://www.haomeiwen.com/subject/hguhhftx.html