views:

40

answers:

3

Hai Guys,

I am getting the leaks as 100%. I don't know how to release the object after it returns Could you explain the procedure how to release the allocated Titles object.

-(Titles *)listTiles
{
Tiles* tile = [[Tiles alloc] init];
 tile.googleTile_X = (int)tileX;
 tile.googleTile_Y = (int) pow(2, aZoom) - 1- tileY ;
 tile.zoomLevel = aZoom; 
 return tile;
}

Thank you, Madan Mohan

+2  A: 

You're sending -alloc, and failing to send -release or -autorelease to the object you've created.

Read Apple's introductory documentation on memory management.

NSResponder
+1  A: 

In general it depends, but in that particular case I believe you can use return [tile autorelease].

P.S.: Please format your code correctly.

NR4TR
+1  A: 
-(Titles *)listTiles
{
    Tiles* tile = [[[Tiles alloc] init] autorelease];
    tile.googleTile_X = (int)tileX;
    tile.googleTile_Y = (int) pow(2, aZoom) - 1- tileY ;
    tile.zoomLevel = aZoom; 
    return tile;
}
trydis