Search code examples
iosobjective-crubymotion

Unrecognized selector sent to UIImage?


hoping you can help me out. Code is Rubymotion but I'm pretty sure it's an iOS issue. Code is simple enough that hopefully it being Rubymotion doesn't get in the way of an answer. And I can read Obj-C, so if you can answer with Obj-C only, I'm good with that.

I have a UIImage object. I'm trying to get the size of it. When I do the following:

image = info.objectForKey(UIImagePickerControllerOriginalImage) 
@image = UIImage.alloc.initWithCIImage(image)
puts @image.to_s
puts @image.size
puts @image.to_s

I get this output:

#<UIImage:0x9513710>
NSInvalidArgumentException: -[UIImage extent]: unrecognized selector sent to instance 0x10fb7410 (RuntimeError)
#<UIImage:0x9513710>

I've read that when you get the extent error, it tends to mean the object has been released and is no longer in memory but if I comment out the .size line, the 3rd line still runs meaning it hasn't been released.

Any ideas?


Solution

  • Somewhere you are using the UIImage instance rather than the CIImage instance... CIImage has a function called "Extent" on it (from a quick google) and UIImage doesn't. Maybe you're passing the image to a function which is using this "Extent" function.