Hi.
Say, I alloc/init a pointer to an object:
NSObject *newObject = [newObject alloc] init];
Now, we add it to an NSArray with addObject:
Now, we release the array.
[array release];
The retain count to newObject should be 1 right now (2 after adding to the array and 1 after array is released).
When I issue [newObject release] is the memory to the POINTER *newObject being reclaimed or both the pointer and the pointed-to object?
Relatedly, when array is released, does it just decrement the retain count or does it decrement the retain count (for newObject) AND also releases the pointed-to object, leaving the pointer (which then points to a memory location that isn't actually being used)?
Thanks.
Say, I alloc/init a pointer to an object:
NSObject *newObject = [newObject alloc] init];
Now, we add it to an NSArray with addObject:
Now, we release the array.
[array release];
The retain count to newObject should be 1 right now (2 after adding to the array and 1 after array is released).
When I issue [newObject release] is the memory to the POINTER *newObject being reclaimed or both the pointer and the pointed-to object?
Relatedly, when array is released, does it just decrement the retain count or does it decrement the retain count (for newObject) AND also releases the pointed-to object, leaving the pointer (which then points to a memory location that isn't actually being used)?
Thanks.