当我点击Xcode中的Build菜单中的“构建和分析”按钮时,我偶然发现了一个问题。分析表明我发布了一个我希望稍后返回的变量。代码如下如下:如何释放即将返回的变量?
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{
//I do some other thing here
MKPinAnnotationView *annView=
[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"addressLocation"];
//I do some other thing here
return annView;
}
我我可以释放annView并不会造成任何问题退货吗?
我想到了。我只是不确定在这种情况下它是否运行良好。请让我知道如果我错了,因为我是一个非常新手在objective-c。 – 2010-08-05 00:44:18
@Winston Chen:这正是'autorelease'的作用。 – dreamlax 2010-08-05 01:05:57