美文网首页
Swift报错 Cannot form weak referen

Swift报错 Cannot form weak referen

作者: 晨煜煌 | 来源:发表于2020-12-15 15:13 被阅读0次
    Cannot form weak reference to instance (0x15919e00) of class ***. It is possible that this object was over-released, or is in the process of deallocation.
    

    具体原因就是 lazy 和 weak 同时使用造成的
    一般会出现在tableview的使用上,用lazy声明了tableview,然后tableview的delegate和datasource都是默认weak,在某些情况下就会造成崩溃。这是因为lazy的加载机制问题,如果在lazy的初始化方法中使用了delegate和DataSource,就好像是在dealloc中使用了weak对象一样,就会crash

    相关文章

      网友评论

          本文标题:Swift报错 Cannot form weak referen

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