开发者

Will this leak memory

开发者 https://www.devze.com 2023-03-22 10:23 出处:网络
I have created a NSTimer and call it every 15 seconds. Method that I call makes web servic开发者_如何学Goe call. In this method I write this code:

I have created a NSTimer and call it every 15 seconds. Method that I call makes web servic开发者_如何学Goe call. In this method I write this code:

GetData *ws = [[GetData alloc]init];
    [ws GetSomeData:156];  
    [ws release];

Here I make instance to a class that call web service method, make a call and release object. Is this approach fine or bad?


No leak here, but if you want to do something with ws, don't release it, autorelease it instead.


That's the right approach. You alloc it, so you own it, and you must release it after you've done something with it.

As as side note, your method name GetSomeData doesn't follow Cocoa naming conventions: it should be someData.

0

精彩评论

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