1

I've a strange behaviour developing an iPad application (languages: C++/Objective-C): it happens that in the simulator everything it's ok, in other words the application run successfully, meanwhile when implementing the program into the device I receive an unintelligible EXC_BAD_ACCESS.

This is a chunk of my code in the Obj-C environment:

-(void) BindTexture:(unsigned char*)TexBuff {  
    // TexBuff is a fild of a pointer list, containing data prevoisly saved  
    UIImager *texImg = (UIImage*)TexBuff;  
    CGImageRef imageRef = [texImage CGImage];  
    ....  
    .... {so on} ...  
}  

The device stucks before the call CGImageRef.
The oddities is the difference between Simulator and the Device.
Have you some idea?

BenMorel
  • 34,448
  • 50
  • 182
  • 322
tokamak
  • 11
  • 3

1 Answers1

0

You are casting an unsigned char* to a UIImage* - this is not a good thing to do and is likely the cause of your EXC_BAD_ACCESS.

Is TexBuff supposed to be your raw data array? If so, see this post for how to convert raw data (RGBA data for example) into a CGImage:

Converting RGB data into a bitmap in Objective-C++ Cocoa

Community
  • 1
  • 1
simeon
  • 4,466
  • 2
  • 38
  • 42
  • Thanks for the replay. actually the distance from the simulator and device is reduced: the appl doesn't work at all. I'll follow your link and I'll take you tuned, if interested – tokamak Jun 06 '11 at 18:18