以下单例类(SharedManager)帮助器方法可能会导致保留周期.在静态分析器中获取警告:“在线路上分配的对象的潜在泄漏……”我该如何解决?
我确实尝试过使用ivar uuid __weak但是当我分析时仍会出现警告.
Nsstring *__weak uuid = (__bridge Nsstring *)CFUUIDCreateString(kcfAllocatorDefault,uuidobject);
谢谢
像这样在课堂上被召唤:
myUUID = [SharedManager generateUUID]; + (Nsstring *)generateUUID { CFUUIDRef uuidobject = CFUUIDCreate(kcfAllocatorDefault); Nsstring *uuid = (__bridge Nsstring *)CFUUIDCreateString(kcfAllocatorDefault,uuidobject); CFRelease(uuidobject); return uuid; }
解决方法
Nsstring *uuid = (__bridge_transfer Nsstring *)CFUUIDCreateString(kcfAllocatorDefault,uuidobject);
这会删除警告吗?