ios - Data corrupt after converting byte[] to NSData -
I have a .NET Web service response in which there is a byte [] entry between other fields. The data is a pdf file.
I extract the dictionary with the data obtained from me: [NSJSONRialization JSONObjectWithData]
After this, I use the following code [NSDT] to convert the byte. Then I save the result to disk (see the last line).
When opening the resulting PDF file, I get the following error:
"Unable to find PDF header:`% PDF 'was not found. " ** While dragging as many as PDFs to many PDFs at the same time, some of the reports received as base 64 strings were also corrupted. PS Please tell me if I have to provide the code from my SVC class, but I do not think there is a problem. Edit: I have a new web service system that takes a byte [] as an input, then to send back the MyTrray variable to my iOS app Is modified, where it is saved in a file, resulting in a PDF file is a valid file which is readable by Adobe. This means that there is no corruption during the transfer. Thank you! OK, in the end I made a stupid mistake, Bar ignored. This line code: : Good times, now I can get some sleep at the end: -)
NSArray * byteArray = [rootDictionary ObjectForcae: @ "File"]; Unsigned C = byterequity; Uint8_t * Bytes = Mallok (size (* bytes) * c); Unsigned i; {NSString * str = [byteArray objectItindex: i]; for i (i = 0; i
NSData * data = [NSData datawaitabytes: (Constant Worth *) Byterere length: Size (unsigned char) * C]; Change in
NSData * Data = [NSDTATA DataWithbites: (Constant Worth *) Bytes Length: SizeOff (unsigned char) * C] ;
Comments
Post a Comment