我經歷了許多示例代碼閱讀和發現,這個分配語句是否適合cllocationmanager?
self.Location = [[CLLocationManager alloc] init];
這種分配在保留Location
對象是有效的?這種內存管理是明智的?
我經歷了許多示例代碼閱讀和發現,這個分配語句是否適合cllocationmanager?
self.Location = [[CLLocationManager alloc] init];
這種分配在保留Location
對象是有效的?這種內存管理是明智的?
去,如果你的屬性爲保留或複製,那麼你被保留並且變量應該被釋放,這看起來很奇怪......所以如果你想在一行中做,你會自動釋放它。
是的,這是完美的,我沒有看到任何問題在這裏。
正如,你正在使用MRC, 您可以
self.Location=[[[CLLocationManager alloc] init] autorelease];
或
self.Location=[[CLLocationManager alloc] init];
,並在dealloc中,[Location release];
我不應該這樣做? location = [[CLLocationManager alloc] init]; self.Location = location; [位置發佈]; – raghul
耶或... self.property = [[Class new] autorelease]; –
感謝Grady Player! – raghul