我有这门课:
@class UIImagePicker;
@protocol UIImagePickerDelegate<NSObject>
@required
- (void)didFinishChooseImage:(UIImagePicker *)picker withImage:(UIImage*)img;
@end
@interface UIImagePicker : NSObject <UINavigationControllerDelegate, UIImagePickerControllerDelegate> {
UIImagePickerController *imgPicker;
}
@property (assign) int type;
@property (nonatomic, retain) UIImagePickerController *imgPicker;
@property (nonatomic,assign) id <UIImagePickerDelegate> delegate;
这就是我分配的方式imgPicker
:
-(void)showImagePicker{
imgPicker = [[UIImagePickerController alloc] init];
imgPicker.allowsEditing = YES;
imgPicker.delegate = self;
//Trigger get photo from library function
if (self.type == 0) {
imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
} else {
imgPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
}
}
这就是我发布的方式imgPicker
:
- (void)dealloc
{
[imgPicker release],imgPicker = nil;
[super dealloc];
}
dealloc 中的释放是否正常?或者我需要添加另一个版本,因为 imgPicker 具有保留属性?