后台返回的数据格式如以下形式:
{"pic":[-1,-40,-1,-31,17,-81,69,120,105,102,0,0,77,77,0,42,0,0,0,8,0,12,1,0,0,3,0]}"
需要把此种格式的数据显示成图片
- (NSData *)convertByteArrayToData:(NSArray *)byteArray { unsigned c = byteArray.count; uint8_t *bytes = malloc(sizeof(*bytes) * c); unsigned i; for (i = 0; i < c; i++) { NSString *str = [byteArray objectAtIndex:i]; int byte = [str intValue]; bytes[i] = (uint8_t)byte; } return [NSData dataWithBytes:bytes length:c]; }
将数据解析后,传给上面的方法,就返回NSData数据了。
需要进行测试的话,可以使用附件中的数据进行测试。