1110
1110

Reputation: 6829

Will this leak memory

I have created a NSTimer and call it every 15 seconds. Method that I call makes web service 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?

Upvotes: 1

Views: 160

Answers (2)

ySgPjx
ySgPjx

Reputation: 10265

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.

Upvotes: 1

user756245
user756245

Reputation:

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

Upvotes: 3

Related Questions