Release an object without a pointer?
Posted
by
Kai Friis
on Stack Overflow
See other posts from Stack Overflow
or by Kai Friis
Published on 2010-12-29T18:58:49Z
Indexed on
2011/01/03
7:53 UTC
Read the original article
Hit count: 247
I’ve just started developing for iPhone and am trying to get my head around memory management. I made a small program that shows a map and an annotation on the map. For the annotation I made a simple class that implements the MKAnnotation protocol.
To create and add the annotation I wrote this:
[self.myMapView addAnnotation:[[MyAnnotation alloc] init]];
It worked fine until I tried to release the object. Nothing to release. This is what I would have done in C#, I guess it doesn’t work without garbage collection?
So is this the only way to do it?
MyAnnotation *myAnnotation = [[MyAnnotation alloc] init];
[self.myMapView addAnnotation: myAnnotation];
[myAnnotation release];
© Stack Overflow or respective owner