【发布时间】:2011-11-16 06:09:30
【问题描述】:
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view {
UILabel *retval = (id)view;
if (!retval) {
retval= [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 0.0f, [pickerView rowSizeForComponent:component].width, [pickerView rowSizeForComponent:component].height)];
}
NSDictionary *destination = [appDelegate.destinations objectAtIndex:row];
retval.text = [destination objectForKey:@"name"];
retval.font = [UIFont systemFontOfSize:18];
return retval;
}
看方法,在XCode中做产品>分析后,我会在行号得到以下警告
return retval;
Potential leak of an object allocated on line 213 and stored into 'retval'
让我知道,这是什么,我将如何发布,
请编辑此代码,并解释一下您在其中做了哪些更改, 谢谢
【问题讨论】:
-
像这样自动释放 retval... retval= [[[UILabel alloc] initWithFrame:CGRectMake(0.0f, 0.0f, [pickerView rowSizeForComponent:component].width, [pickerView rowSizeForComponent:component]。高度)]自动释放];