0

I have read through many sample codes and found that,

self.Location = [[CLLocationManager alloc] init];

this kind of allocation over a retained Location object is valid? this kind of memory management is it advisable??

4

2 回答 2

2

Yes this is perfect, I don't see any problem here.

As, you are using MRC, You can go with

self.Location=[[[CLLocationManager alloc] init] autorelease];

or

 self.Location=[[CLLocationManager alloc] init];

and in the dealloc, [Location release];

于 2013-03-30T04:31:50.400 回答
1

if your propery is retain or copy then you are over retained and the variable should be released, which looks strange... so if you want to do it in one line you would autorelease it.

于 2013-03-30T04:37:01.623 回答