tags:

views:

9

answers:

1
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view {

    CGRect imageFrame = CGRectMake(0.0, 0.0, 15, 15);
    UIImageView *label = [[UIImageView alloc] initWithFrame:imageFrame];

    if (row == 0)
    {
        label.backgroundColor = [UIColor redColor];
    }
    if (row == 1)
    {
        label.backgroundColor = [UIColor blueColor];
    }
    if (row == 2)
    {
        label.backgroundColor = [UIColor blackColor];
    }   
    return label;
}

label is a leak. i know it. but....

+2  A: 

Just do [label autorelease]; before the return

Aleph
does autorelease work on ios??
griotspeak
Here's a good description of when to use autorelease. http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmObjectOwnership.html#//apple_ref/doc/uid/20000043-SW5
Robot K