- (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;
}
See the mothod, After doing Product > Analyze in XCode, I will get the following warning at line number
return retval;
Potential leak of an object allocated on line 213 and stored into 'retval'
Let me know, what is this, how would I do release,
Please edit this code, and explain me what have you changed in it,
Thanks
Just when you allocate the label, keep it in autorelease mode, as you’ll need to release RETVAL somewhere. You haven’t released it, hence a leak is found.