I am having a strange issue wh开发者_如何学运维ere the static analyzer throws a warning 'object allocated on line xxx is not referenced later in this execution path and has a retain count of +1 (object leaked)' on
self.myProperty = [[aClass alloc] initWithObject:anObject];
Since this is a property of my ViewController class, I need the object everywhere in the class and I am releasing the object in the dealloc method.
[myProperty release];
myProperty = nil;
At first I released the object in dealloc as
[self.myProperty release];
and at that time the warning on the allocation part was gone, but another one came up in the release line 'Incorrect decrement of the reference count of an object that is not owned at this point by the caller'.
How to fix this?
Does the setter for myProperty also retain the object? That might explain the leak warning.
精彩评论