Shamsiddin Shamsiddin - 3 months ago 7x
iOS Question

Check if UIImage property got assigned or not?

I have an

property, and after shooting image from iPhone camera I assigned image object to this property, otherwise not.
How can I check if this property contains image after shooting or not?
Below my code didn't help.

@interface MyViewController : UIView<UINavigationControllerDelegate, UIImagePickerControllerDelegate>
@property(nonatomic, retain) UIImage *imageShot;

@implementation MyViewController
@synthesize imageShot = _imageShot;

- (id)init {
self = [super init];
if (self) {
_imageShot = [[UiImage alloc] init];

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
self.imageShot = [info objectForKey:UIImagePickerControllerEditedImage];

- (void)buttonClick {
if (_imageShot) {

else {




In your init, you should create shotedImage with nil instead of alloc'ing a new, empty image. That'll allow to perform tests like if (!shotedImage) (as nil == 0).