我有这堂课:
@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具有retain属性??