For some reason, when I try to create a sprite with a texture, my app crashes. I'm creating the texture from a UIImage created when you use the UIImagePickerController class, and apparently the sprite's initWithTexture method doesn't like this. Here's my code:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[picker dismissModalViewControllerAnimated:YES];
[image release]; //image is defined as a UIImage
image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
[image retain];
Photolayer* photo = [Photolayer GetMe];
Texture2D* tex = [[Texture2D alloc] initWithImage:image];
if(tex) //I thought that initWithImage^ might be returning nil. Apparently it isn't
{
[photo SetSprite:[[Sprite node] initWithTexture:tex]];
}
// [photo addChild: [photo GetSprite]];
[tex release];
The GetMe, SetSprite, and GetSprite methods all do exactly what they appear to do; they return a object or change it, nothing else. Regardless, it says the following when the app crashes:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** +[Photolayer SetSprite:]: unrecognized selector sent to class 0x32960'
which I can only assume means that my texture isn't a texture, or my sprite isn't a sprite. Can anyone tell me where I went wrong, or how I can isolate the issue (I am unsure how exactly I'm going to find out whether my sprite or texture isn't what it should be)? Thanks.