Search code examples
iphoneiosmemory-managementautoreleaseaddsubview

Memory management addSubview:


I have a UIPickerView that I allocated as an autoreleased object and use a @property (nonatomic,retain) on self to hold on to it. When I make it visible by calling [self.view addSubview:self.picker], should I call [self.picker release] afterwards? I've been doing that but the Xcode analyzer says "Incorrect decrement of the reference count of an object that is not owned at this point by the caller".

Thanks!


Solution

  • No. You've already autoreleased your UIPickerView. I'm assuming you're releasing the property reference in your dealloc method. That's all you have to do. The view is responsible for the subview after you've assigned it.