Cocoa-Touch:内存管理

Pro*_*ody 0 iphone cocoa cocoa-touch objective-c

我正在自定义UIPickerView的行,所以我在它的委托中实现了viewForRow方法,如下所示:

- (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;
    }    
}
Run Code Online (Sandbox Code Playgroud)

我是Obj-C的新手.

由于我是aloc/initing l,我应该根据内存管理指南发布它.但是我还需要退货.自动释放它可以吗?

rei*_*ein 10

是的autoreleasing就在这里.