tags:

views:

30

answers:

1

Hi,

Is there a way I can check if there is valid Image in my UIImage object?

Thanks

A: 

It depends on what you mean by a valid image. If you do

[UIImage imageNamed:]

and the image isn't valid, it will return nil, so you can do:

UIImage *myImage = [UIImage imageNamed:@"yourImageName.png"]

if (myImage != nil) { ... }

Mike Krieger
Sorry Mike I haven't made my question quite clear. I am initializing an image with a URLString. In my case sometimes there would be an image on remote site and sometimes not. I have read the data by converting it into string and it says in title '404 Not Found'. I have also tried using NSPredicate to see if return string contains '404 Not Found' in it so I can put in place proper validation but it is not working. I would really appreciate if someone could help me in right direction. Thanks
Leo