I'm wondering how I can save the content of an int8 array to a file. I found that if the "actual content" represented by the int8 array is an String, then my code runs fine. But if the content is actually an image, the saved file cannot be opened (says it's damaged).
I tried to open the image using the text editor and found that the content is different from what was expected (I have the "good" image which can be used for comparison). I'm wondering if it's something to do with encoding ?
The int8 array is the raw data from a HTTP response (HTTP part is written in C).
I'm not sure if i'm on the right track, any ideas ?
var response: NSData! = NSData(bytes: myArray, length: contentLength)
var writeOutput: Bool = response.writeToURL(thePath, atomically: false)
How can I modify the code so that it saves the content properly no matter if the content is text or image.
Thanks a lot~
unsigned char[]. If you've been collecting this data as Int8, that could be the source of the trouble.