I'm customizing a UIPickerView's rows, so I'm implementing the viewForRow method in it's delegate as follows:
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view {
if (view) {
return view;
} else {
NSString *s = [datePickerValues objectAtIndex:row];
UILabel *l = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 300, 44)];
l.text = s;
l.font = [UIFont boldSystemFontOfSize:18];
l.textAlignment = UITextAlignmentCenter;
l.backgroundColor = [UIColor purpleColor];
[l autorelease];
return l;
}
}
I'm new to Obj-C.
Since I'm aloc/initing l, I'm supposed to also release it according to the memory management guide. However I need to also return it. Is autoreleasing it OK?