Data corrupt after converting byte[] to NSData

淺唱寂寞╮ 提交于 2019-12-02 00:26:40

O.k, finally sorted this out after fine-tooth-combing my code (as inspired by snadeep.gvn from http://www.raywenderlich.com/forums/viewtopic.php?f=2&p=38590#p38590).

I made a stupid mistake, which I overlooked 100+ times.

This line of code:

NSData* data = [NSData dataWithBytes:(const void *)byteArray length:sizeof(unsigned char)*c];

Should change to:

NSData* data = [NSData dataWithBytes:(const void *)bytes length:sizeof(unsigned char)*c];

Good times, now I can finally get some sleep :-)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!