Incorrect decrement of the reference count of an object that is not owned at this point by the caller

前端 未结 1 890
一向
一向 2020-12-15 14:25

I have a very simple Person class that has a ivar called name ( an NSString). When I try to release this ivar in dealloc the static analyzer gives me a weird error:

相关标签:
1条回答
  • 2020-12-15 14:56

    You're releasing an object returned from a property getter method, which in many cases would be the indication of a possible bug. That's why the static analysis is picking it up.

    Instead, use:

    self.name = nil;
    

    or:

    [name release];
    name = nil;
    
    0 讨论(0)
提交回复
热议问题