HI all,
What happens if you repeat the following code more than once ?
pointer * mypointer = [[object alloc]init];
Do you just increase the retain count of that object by one again ?
Thanks,
Martin
HI all,
What happens if you repeat the following code more than once ?
pointer * mypointer = [[object alloc]init];
Do you just increase the retain count of that object by one again ?
Thanks,
Martin
You wouldn't increase the retain count - only the retain
message does that on an allocated object. Running that exact code more than once would actually error out, since you'd be duplicating the pointer * mypointer
type declaration. However, if you had (for example):
pointer * mypointer = [[object alloc] init];
mypointer = [[object alloc] init];
You would have made two instances of object
, each at its own position in memory, and you would have lost your handle on the first one (since mypointer
now contains a reference to the second instance of object
). Effectively, this is a leak.