我做了一個構建和分析,並被警告存儲在'locationManager'中的對象的潛在泄漏。我想知道如何正確處理這個問題。下面的代碼:如何處理對象警告的潛在泄漏 - CLLocationManager
//指南針代碼
CLLocationManager *locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
if ([CLLocationManager locationServicesEnabled] &&
[CLLocationManager headingAvailable]) {
[locationManager startUpdatingLocation];
[locationManager startUpdatingHeading];
locationManager.headingFilter = 2; // 2 degrees
} else {
NSLog(@"Can't report heading");
}
感謝您的幫助