开发者

I am getting the leak in the following code

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 开发者_JAVA技巧= aZoom; 
 return tile;
}


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.


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

P.S.: Please format your code correctly.


-(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;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜