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. "

  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  

** 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:

  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] ;   

Good times, now I can get some sleep at the end: -)

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -