我有一些CLLocation的內存問題。CLLocation內存問題
CLLocation *annotation = [[CLLocation alloc] initWithLatitude:[[tempDict objectForKey:@"lat"] doubleValue] longitude:[[tempDict objectForKey:@"lon"]doubleValue]];
CLLocation *item2 = [[CLLocation alloc] initWithLatitude:[newLatString doubleValue] longitude:[newLongString doubleValue]];
cell.detailTextLabel.text = [NSString stringWithFormat:@"%.1f km",[item2 distanceFromLocation:annotation]/1000];
[annotation release];
[item2 release];
所以我試圖做到這一點,但我意識到你不能設置註釋的座標。
CLLocationCoordinate2D tempCoordinate = annotation.coordinate;
tempCoordinate.latitude = [[tempDict objectForKey:@"lat"] doubleValue];
tempCoordinate.longitude = [[tempDict objectForKey:@"lon"] doubleValue];
annotation.coordinate = tempCoordinate;
有沒有解決方法呢?我並不想成爲分配/ INITING一個CLLocation每次的cellForRowAtIndexPath被稱爲..
我在做CLLocations,所以我可以得到distanceFromLocation。基本上我正在製作一個UITableView,這些商店和他們距離我目前的位置的距離。 – 2010-09-28 03:42:55