NSString from NSData is incomplete - ios

When I use [[NSString alloc] initWithData:subdata encoding:encoding] method , I find the string is incomplete. Why? Any restrictions in NSString?
Then,I suspect that the data is too large,so I create a new method to Transfer.
-(NSString *)stringFromData:(NSData *)data encoding:(NSStringEncoding)encoding{
NSInteger DataLen = data.length;
NSInteger segLen = 5000;
NSInteger times = DataLen/segLen;
NSInteger fristLen = DataLen%segLen;
NSMutableString *str = [NSMutableString string];
[str appendString:[[NSString alloc] initWithData:[data subdataWithRange:NSMakeRange(0, fristLen)] encoding:encoding]];
NSLog(#"%#",str);
while (times--) {
NSData *subdata = [data subdataWithRange:NSMakeRange(fristLen, segLen)] ;
if (subdata) {
NSString*substr = [[NSString alloc] initWithData:subdata encoding:encoding]; //tag1
NSLog(#"%#",substr);
if (substr) {
[str appendString:substr];
}
fristLen += segLen;
}else{
break;
}
}
return str;
}
but in tag1, I find the string is null in some conditions. What is the problem?

Related

How to convert a string into hex value and get string back from hex value

I have a scenario where i want to convert a string into HexValue and fetch string from HexValue
For e.g i have a string with value '33' in it . So when i convert it to hex i get the result as '21' and when i convert '21' which is the hex value back to string i should get '33' back as the output.
Following is the code which i have done for converting string into hex
+ (NSString *) hexValue:(NSString *)str {
return [NSString stringWithFormat:#"%lX",
(unsigned long)[str integerValue]];
}
so when i pass '33' to this method it returns '21' which is correct
but the problem is i want to retrieve '33' back from '21'
Following is the code
+ (NSString *) unHexValue:(NSString *)str {
return [NSString stringWithFormat:#"%#",str];
}
but this does not return the expected value which is '33'. Instead it returns 21 only.
It is working for me and able to fetch same result.Hope it will help you.
NSString *strHex = [self hexfromString:#"33"];
NSString *newStr = [self stringFromHexString:strHex];
// Hex from String
- (NSString *)hexfromString:(NSString *)str
{
NSUInteger len = [str length];
unichar *chars = malloc(len * sizeof(unichar));
[str getCharacters:chars];
NSMutableString *hexString = [[NSMutableString alloc] init];
for(NSUInteger i = 0; i < len; i++ )
{
// [hexString [NSString stringWithFormat:#"%02x", chars[i]]]; /*previous input*/
[hexString appendFormat:#"%02x", chars[i]]; /*EDITED PER COMMENT BELOW*/
}
free(chars);
return hexString;
}
// string From HexString
- (NSString *)stringFromHexString:(NSString *)hexString {
// The hex codes should all be two characters.
if (([hexString length] % 2) != 0)
return nil;
NSMutableString *string = [NSMutableString string];
for (NSInteger i = 0; i < [hexString length]; i += 2) {
NSString *hex = [hexString substringWithRange:NSMakeRange(i, 2)];
NSInteger decimalValue = 0;
sscanf([hex UTF8String], "%x", &decimalValue);
[string appendFormat:#"%c", decimalValue];
}
return string;
}

NSMutableArray have restriction in adding object?

I am using NSMutableArray for adding objects.But its add only first 10 objects.
I have code for sharing
for (int j = 0; j<[feedData count]; j++)
{
[sharingItems addObject:[self whatsappdata:[feedData objectAtIndex:j]]];
}
This method return NSString type text.
Please provide me valid solution for this.
Thanks in Advance
-(NSString *)whatsappdata:(NSDictionary *)cellData1
{
NSString *brandName = [NSString stringWithFormat:#"%#", [cellData1 objectForKey:#"brand_name"]];
NSString *modelName = [NSString stringWithFormat:#"%#", [cellData1 objectForKey:#"brand_model_name"]];
NSString *version = [NSString stringWithFormat:#"%#", [cellData1 objectForKey:#"version_name"]];
if ([version isEqualToString: #"<null>"])
{
version = #"";
}
NSString *year = [NSString stringWithFormat:#"%#", [cellData1 objectForKey:#"model_year"]];
if (year == nil || [year isEqualToString:#"0"])
{
year = #"";
}
NSString *inventoryValue = [NSString stringWithFormat:#"%#",[cellData1 objectForKey:#"inventory_type"]];
NSInteger value = [inventoryValue intValue];
NSString *inventoryName;
NSString *msg;
if(value == 1)
{
inventoryName = [NSString stringWithFormat:#"%#", #"Stock"];
i++;
NSString *text2 = [NSString stringWithFormat:#"%d.%# %# %#- %# Single Owner\n",i, brandName, modelName, version, year];
msg = [NSString stringWithFormat:#"%#",text2];
msg= [msg stringByReplacingOccurrencesOfString:#"\n" withString:#"<br/>"];
}
else
{
inventoryName = [NSString stringWithFormat:#"%#", #"Required"];
msg = #"";
}
return msg;
//end data
}
Most probably "fetch limit" has set for 'NSFetchRequest' inside your code.
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
[fetchRequest setFetchLimit:10];//such code you need to find and remove/change fetch limit
you need to allocate memory to array before adding elements
sharingItems = [[NSMutableArray alloc]init];

Convert HEX NSString to an ASCII NSString

I got an NSString containing a hex value which I would like to convert in ASCII. How can I do this?
NSString * hexString = // some value
NSString * asciiString = // ? convert hexString to ASCI somehow
INCORRECT APPROACH THAT I TRIED:
I tried the following approach that I found on a similar question but it did not work for me:
NSData *_data = [hexString dataUsingEncoding:NSUTF8StringEncoding];
NSMutableString *_string = [NSMutableString stringWithString:#""];
for (int i = 0; i < _data.length; i++) {
unsigned char _byte;
[_data getBytes:&_byte range:NSMakeRange(i, 1)];
if (_byte >= 32 && _byte < 127) {
[_string appendFormat:#"%c", _byte];
} else {
[_string appendFormat:#"[%d]", _byte];
}
}
asciiString = _string; // Still shows the same as before..
this works for me:
NSString * str = #"312d4555";
NSMutableString * newString = [[NSMutableString alloc] init];
int i = 0;
while (i < [str length]){
NSString * hexChar = [str substringWithRange: NSMakeRange(i, 2)];
int value = 0;
sscanf([hexChar cStringUsingEncoding:NSASCIIStringEncoding], "%x", &value);
[newString appendFormat:#"%c", (char)value];
i+=2;
}
NSLog(#"%#", newString);
output is: hello

Printing from NSMutableArray

So i want to print the users in an NSMutableArray. But the strings keep coming out as nil.
here is what i have:
int users = 0;
- (IBAction)addNewUser:(id)sender {
NSString *string;
string = userNameTextField.text;
[usernameArray insertObject:string atIndex:users];
users++;
[self showUsers];
}
-(void)showUsers{
for (int i = 0; i < users; i++){
NSString *s = textView.text;
NSString *add;
add = [NSString stringWithFormat:#"%# ",[usernameArray objectAtIndex:i]];
NSString *display = [NSString stringWithFormat:#"%# \n %#", s, add];
textView.text = display;
}
}
i have also tried
-(void)showUsers{
for (int i = 1; i < users; i++){
NSString *s = textView.text;
NSString *add;
add = [usernameArray objectAtIndex:i];
NSString *display = [NSString stringWithFormat:#"%# \n %#", s, add];
textView.text = display;
}
}
First of all try using more comprehensive names for the objects. I'm rewriting your code.
Common Causes for the problem : Array not initialized, you are starting your for cycle with int i equal to 1, so you are missing the object at index 0 at your mutable array. Try the following code.
#interface InterfaceName : InterfaceInherits <IfDelegate> {
int usersCount;
NSMutableArray * usernameArray;
}
#implementation InterfaceName
/*There's no more confident way to initialize a variable than in the init method of the class. */
-(id)init{
usersCount = 0;
//You have to be sure that your array is not nil
usernameArray = [NSMutableArray alloc]init]];
return self;
}
- (IBAction)addNewUser:(id)sender {
NSString *username = [usernameTextField text];
[usernameArray insertObject:username atIndex:usersCount];
usersCount++;
//I'll omit the display as I'm not sure what you were doing with it.
}
-(void)showUsers{
for (int i = 0; i < usersCount; i++){
NSString *retrievedUser = [usernameArray objectAtIndex:i];
NSString *display = [NSString stringWithFormat:#"User Retrieved : %#",retrievedUser];
textView.text = display;
}
}
#end

How do I convert a byte array to UIImage

I have a webservice which sends me back an array of bytes like this:
<ax23:IMGBLOB>-119,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,100,0,0,0,106,8,3,0,0,0,125,54,4,22,0,0,0,51,80,76,84,69,0,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-73,-107,-30,-126,0,0,0,16,116,82,78,83,0,16,32,48,64,80,96,112,-128,-112,-96,-80,-64,-48,-32,-16,84,-32,-88,-56,0,0,2,126,73,68,65,84,120,-38,-19,90,65,-110,-124,32,12,4,68,64,69,-32,-1,-81,-35,-53,-78,-96,40,4,-79,-70,118,-86,-90,-113,51,106,-101,116,-120,33,-127,-3,43,72,101,-84,13,127,-80,-42,40,-7,42,-63,100,108,-72,-124,53,-45,75,38,-84,62,84,-32,-41,97,-125,-72,118,-95,9,-89,-7,0,-123,-56,-115,-88,-101,35,-98,90,-79,-122,14,-84,-113,-84,49,62,116,-63,-101,126,-71,-9,112,-58,-66,25,45,127,-95,-51,118,113,-127,-20,52,-29,124,-1,34,121,-31,78,-71,-100,-119,76,-113,-32,-5,-111,65,-117,-37,43,-11,-23,82,65,118,-107,63,40,42,91,-21,-24,-96,12,-47,101,-22,64,33,8,-122,31,104,20,-123,99,9,9,-106,104,-67,-80,-7,123,-79,38,-78,-73,114,51,35,99,118,29,44,-21,-45,-27,-59,-13,59,-87,-66,-14,-118,117,66,-91,120,89,104,-102,-69,7,57,124,114,20,-11,101,-118,119,-2,40,-37,-91,69,35,111,99,-60,-25,28,99,44,-2,46,46,-9,-100,99,-108,101,-81,-28,-85,-56,49,-50,98,-86,-126,56,-50,6,-64,93,41,75,-23,44,63,13,86,29,-2,-34,97,38,69,-33,32,-44,-83,-61,-72,-89,-26,4,122,102,-14,-68,-8,-93,16,100,80,-106,-14,-123,69,52,113,102,47,96,-114,79,19,-105,-122,88,-10,10,-74,43,83,-72,-49,-87,-57,33,-82,84,-47,45,-43,-71,-115,5,92,-97,-10,-102,37,-72,104,72,-43,126,111,120,-81,41,46,91,-20,-51,-16,-115,-9,-88,94,83,100,-15,-53,116,79,18,97,37,113,-35,23,-17,-19,99,30,-72,5,-79,-24,45,-77,-108,63,-77,-22,54,9,-67,-24,-43,39,-17,-104,40,123,-101,-124,94,-58,-120,83,2,-77,77,111,-79,112,-126,-99,-88,-2,-78,-57,39,24,2,73,-62,-62,-119,53,-5,49,-128,101,23,73,-16,21,9,-53,-57,-86,72,73,35,73,112,-110,17,-18,81,-71,93,59,-103,36,-63,-118,-74,40,38,-41,125,35,-112,-108,48,-68,-107,-118,109,78,98,-70,72,8,-27,-84,73,36,-55,119,68,18,-54,86,-79,-44,-102,16,92,44,84,-79,93,74,35,7,73,74,-97,1,72,66,-104,-21,36,60,102,-78,33,18,-53,10,8,8,9,-64,93,31,41,-4,90,13,97,-56,98,-124,-92,21,72,-126,28,77,-11,27,37,-43,67,62,90,-112,-49,47,-94,-112,24,40,-119,4,-71,36,-126,20,119,-112,50,21,89,112,-89,-51,68,-101,-60,78,-99,91,7,-56,38,8,-79,-99,-125,108,76,-79,91,-20,-9,-101,5,54,122,6,-46,-10,64,52,112,32,-83,40,68,83,13,-47,30,-124,52,58,17,45,91,68,-13,25,-46,70,71,12,4,16,-93,13,-64,-112,102,37,-113,-101,-74,-66,113,-45,22,18,7,98,112,6,29,1,-30,-121,-103,-8,-79,108,57,96,118,-75,1,-77,43,6,-52,-128,81,57,116,-24,-113,63,-66,-128,63,-120,-127,63,82,66,63,28,99,56,-2,-104,15,-2,-64,-46,-8,-47,-85,47,-66,-8,-30,-77,-16,3,-74,-58,-81,-89,-116,-22,56,-74,0,0,0,0,73,69,78,68,-82,66,96,-126,####</ax23:IMGBLOB>
This array of bytes are used in Java for obtaining an image, I've been trying with several methods without success, I will post one of them below:
-(UIImageView *)convierteImagen: (NSMutableString *)cadenaImagen{
//NSString to NSData (temporary)
NSData *tempData = [cadenaImagen dataUsingEncoding:NSUTF8StringEncoding];
//NSLog(#"datos crudos: %#", tempData);
//2.NSData to Bytes
const void *bytes2 = [tempData bytes];
int8_t *bytes = (int8_t*)bytes2;
int len = tempData.length;
cadenaImagen = [[NSMutableString alloc]init];
[cadenaImagen appendString:#"["];
for (int i = 0; i < len; i++) {
if (i) [cadenaImagen appendString:#","];
[cadenaImagen appendFormat:#"%d", bytes[i]];
}
[cadenaImagen appendString:#"]"];
//3.Bytes to NSData
NSData *datos2 = [NSData dataWithBytes:bytes length:len];
return [[UIImageView alloc]initWithImage:[UIImage imageWithData:datos2]];
}
and the way I call this method is:
- (void)viewDidLoad
{
[super viewDidLoad];
NSMutableString *imagen = [[NSMutableString alloc] initWithString:#"-119,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,100,0,0,0,106,8,3,0,0,0,125,54,4,22,0,0,0,51,80,76,84,69,0,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-73,-107,-30,-126,0,0,0,16,116,82,78,83,0,16,32,48,64,80,96,112,-128,-112,-96,-80,-64,-48,-32,-16,84,-32,-88,-56,0,0,2,126,73,68,65,84,120,-38,-19,90,65,-110,-124,32,12,4,68,64,69,-32,-1,-81,-35,-53,-78,-96,40,4,-79,-70,118,-86,-90,-113,51,106,-101,116,-120,33,-127,-3,43,72,101,-84,13,127,-80,-42,40,-7,42,-63,100,108,-72,-124,53,-45,75,38,-84,62,84,-32,-41,97,-125,-72,118,-95,9,-89,-7,0,-123,-56,-115,-88,-101,35,-98,90,-79,-122,14,-84,-113,-84,49,62,116,-63,-101,126,-71,-9,112,-58,-66,25,45,127,-95,-51,118,113,-127,-20,52,-29,124,-1,34,121,-31,78,-71,-100,-119,76,-113,-32,-5,-111,65,-117,-37,43,-11,-23,82,65,118,-107,63,40,42,91,-21,-24,-96,12,-47,101,-22,64,33,8,-122,31,104,20,-123,99,9,9,-106,104,-67,-80,-7,123,-79,38,-78,-73,114,51,35,99,118,29,44,-21,-45,-27,-59,-13,59,-87,-66,-14,-118,117,66,-91,120,89,104,-102,-69,7,57,124,114,20,-11,101,-118,119,-2,40,-37,-91,69,35,111,99,-60,-25,28,99,44,-2,46,46,-9,-100,99,-108,101,-81,-28,-85,-56,49,-50,98,-86,-126,56,-50,6,-64,93,41,75,-23,44,63,13,86,29,-2,-34,97,38,69,-33,32,-44,-83,-61,-72,-89,-26,4,122,102,-14,-68,-8,-93,16,100,80,-106,-14,-123,69,52,113,102,47,96,-114,79,19,-105,-122,88,-10,10,-74,43,83,-72,-49,-87,-57,33,-82,84,-47,45,-43,-71,-115,5,92,-97,-10,-102,37,-72,104,72,-43,126,111,120,-81,41,46,91,-20,-51,-16,-115,-9,-88,94,83,100,-15,-53,116,79,18,97,37,113,-35,23,-17,-19,99,30,-72,5,-79,-24,45,-77,-108,63,-77,-22,54,9,-67,-24,-43,39,-17,-104,40,123,-101,-124,94,-58,-120,83,2,-77,77,111,-79,112,-126,-99,-88,-2,-78,-57,39,24,2,73,-62,-62,-119,53,-5,49,-128,101,23,73,-16,21,9,-53,-57,-86,72,73,35,73,112,-110,17,-18,81,-71,93,59,-103,36,-63,-118,-74,40,38,-41,125,35,-112,-108,48,-68,-107,-118,109,78,98,-70,72,8,-27,-84,73,36,-55,119,68,18,-54,86,-79,-44,-102,16,92,44,84,-79,93,74,35,7,73,74,-97,1,72,66,-104,-21,36,60,102,-78,33,18,-53,10,8,8,9,-64,93,31,41,-4,90,13,97,-56,98,-124,-92,21,72,-126,28,77,-11,27,37,-43,67,62,90,-112,-49,47,-94,-112,24,40,-119,4,-71,36,-126,20,119,-112,50,21,89,112,-89,-51,68,-101,-60,78,-99,91,7,-56,38,8,-79,-99,-125,108,76,-79,91,-20,-9,-101,5,54,122,6,-46,-10,64,52,112,32,-83,40,68,83,13,-47,30,-124,52,58,17,45,91,68,-13,25,-46,70,71,12,4,16,-93,13,-64,-112,102,37,-113,-101,-74,-66,113,-45,22,18,7,98,112,6,29,1,-30,-121,-103,-8,-79,108,57,96,118,-75,1,-77,43,6,-52,-128,81,57,116,-24,-113,63,-66,-128,63,-120,-127,63,82,66,63,28,99,56,-2,-104,15,-2,-64,-46,-8,-47,-85,47,-66,-8,-30,-77,-16,3,-74,-58,-81,-89,-116,-22,56,-74,0,0,0,0,73,69,78,68,-82,66,96,-126"];
[self.view addSubview:[self convierteImagen:imagen]];
}
Any help I will appreciate :)
try this:
-(UIImageView *)convierteImagen: (NSMutableString *)cadenaImagen{
NSArray *strings = [cadenaImagen componentsSeparatedByString:#","];
unsigned c = strings.count;
uint8_t *bytes = malloc(sizeof(*bytes) * c);
unsigned i;
for (i = 0; i < c; i++)
{
NSString *str = [strings objectAtIndex:i];
int byte = [str intValue];
bytes[i] = (uint8_t)byte;
}
NSData *datos = [NSData dataWithBytes:bytes length:c];
UIImage *image = [UIImage imageWithData:datos];
return [[UIImageView alloc]initWithImage:image];
}
on viewdidLoad is the same code you put:
- (void)viewDidLoad
{
[super viewDidLoad];
NSMutableString *imagen = [[NSMutableString alloc] initWithString:#"-119,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,100,0,0,0,106,8,3,0,0,0,125,54,4,22,0,0,0,51,80,76,84,69,0,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-73,-107,-30,-126,0,0,0,16,116,82,78,83,0,16,32,48,64,80,96,112,-128,-112,-96,-80,-64,-48,-32,-16,84,-32,-88,-56,0,0,2,126,73,68,65,84,120,-38,-19,90,65,-110,-124,32,12,4,68,64,69,-32,-1,-81,-35,-53,-78,-96,40,4,-79,-70,118,-86,-90,-113,51,106,-101,116,-120,33,-127,-3,43,72,101,-84,13,127,-80,-42,40,-7,42,-63,100,108,-72,-124,53,-45,75,38,-84,62,84,-32,-41,97,-125,-72,118,-95,9,-89,-7,0,-123,-56,-115,-88,-101,35,-98,90,-79,-122,14,-84,-113,-84,49,62,116,-63,-101,126,-71,-9,112,-58,-66,25,45,127,-95,-51,118,113,-127,-20,52,-29,124,-1,34,121,-31,78,-71,-100,-119,76,-113,-32,-5,-111,65,-117,-37,43,-11,-23,82,65,118,-107,63,40,42,91,-21,-24,-96,12,-47,101,-22,64,33,8,-122,31,104,20,-123,99,9,9,-106,104,-67,-80,-7,123,-79,38,-78,-73,114,51,35,99,118,29,44,-21,-45,-27,-59,-13,59,-87,-66,-14,-118,117,66,-91,120,89,104,-102,-69,7,57,124,114,20,-11,101,-118,119,-2,40,-37,-91,69,35,111,99,-60,-25,28,99,44,-2,46,46,-9,-100,99,-108,101,-81,-28,-85,-56,49,-50,98,-86,-126,56,-50,6,-64,93,41,75,-23,44,63,13,86,29,-2,-34,97,38,69,-33,32,-44,-83,-61,-72,-89,-26,4,122,102,-14,-68,-8,-93,16,100,80,-106,-14,-123,69,52,113,102,47,96,-114,79,19,-105,-122,88,-10,10,-74,43,83,-72,-49,-87,-57,33,-82,84,-47,45,-43,-71,-115,5,92,-97,-10,-102,37,-72,104,72,-43,126,111,120,-81,41,46,91,-20,-51,-16,-115,-9,-88,94,83,100,-15,-53,116,79,18,97,37,113,-35,23,-17,-19,99,30,-72,5,-79,-24,45,-77,-108,63,-77,-22,54,9,-67,-24,-43,39,-17,-104,40,123,-101,-124,94,-58,-120,83,2,-77,77,111,-79,112,-126,-99,-88,-2,-78,-57,39,24,2,73,-62,-62,-119,53,-5,49,-128,101,23,73,-16,21,9,-53,-57,-86,72,73,35,73,112,-110,17,-18,81,-71,93,59,-103,36,-63,-118,-74,40,38,-41,125,35,-112,-108,48,-68,-107,-118,109,78,98,-70,72,8,-27,-84,73,36,-55,119,68,18,-54,86,-79,-44,-102,16,92,44,84,-79,93,74,35,7,73,74,-97,1,72,66,-104,-21,36,60,102,-78,33,18,-53,10,8,8,9,-64,93,31,41,-4,90,13,97,-56,98,-124,-92,21,72,-126,28,77,-11,27,37,-43,67,62,90,-112,-49,47,-94,-112,24,40,-119,4,-71,36,-126,20,119,-112,50,21,89,112,-89,-51,68,-101,-60,78,-99,91,7,-56,38,8,-79,-99,-125,108,76,-79,91,-20,-9,-101,5,54,122,6,-46,-10,64,52,112,32,-83,40,68,83,13,-47,30,-124,52,58,17,45,91,68,-13,25,-46,70,71,12,4,16,-93,13,-64,-112,102,37,-113,-101,-74,-66,113,-45,22,18,7,98,112,6,29,1,-30,-121,-103,-8,-79,108,57,96,118,-75,1,-77,43,6,-52,-128,81,57,116,-24,-113,63,-66,-128,63,-120,-127,63,82,66,63,28,99,56,-2,-104,15,-2,-64,-46,-8,-47,-85,47,-66,-8,-30,-77,-16,3,-74,-58,-81,-89,-116,-22,56,-74,0,0,0,0,73,69,78,68,-82,66,96,-126"];
[self.view addSubview:[self convierteImagen: imagen]];
}
this is what I got with your byte array:
so I think this should solve your problem ;)

Resources