I often see when we release an ab object, we immediately set it to nil. I know that release and zero release the old value associated with the object, but in the case of release, it leaves the object as a dangling pointer, so we must set it to zero.
So my question is that nil frees the old value of the object and sets the object to nil, why we should not use only nil, why w should also use release.
Way1:
MyClass *obj = [[MyClass alloc] init]; [obj release]; obj = nil;
Way2:
MyClass *obj = [[MyClass alloc] init]; obj = nil;
What is the real difference in way1 and way2 if way1 is used Why don't you use way2 only?
memory-management iphone cocoa-touch xcode
Madhup singh yadav
source share