2013-03-30 26 views

回答

1

去,如果你的屬性爲保留或複製,那麼你被保留並且變量應該被釋放,這看起來很奇怪......所以如果你想在一行中做,你會自動釋放它。

+0

我不應該這樣做? location = [[CLLocationManager alloc] init]; self.Location = location; [位置發佈]; – raghul

+0

耶或... self.property = [[Class new] autorelease]; –

+0

感謝Grady Player! – raghul

2

是的,這是完美的,我沒有看到任何問題在這裏。

正如,你正在使用MRC, 您可以

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

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

,並在dealloc中,[Location release];

+0

我不應該這樣做? location = [[CLLocationManager alloc] init]; self.Location = location; [位置發佈]; – raghul

+0

這會在ARC中自動發佈。 –

+0

我不是通過ARC做的,我爲我的項目 – raghul