IOS: download, spread, decode and analyze a large file

The project I'm working on (iPhone / Obj-C) requires me to receive a large file (via an HTTP message) and process it. The server will return some XML data encoded in BASE64 format, gzipped XML data. i.e.: SERVER → XML → BASE64 → GZIP → XML → My Model

The amount of data will vary, but they tell me that the final XML will be around 5 MB.

I would like to unpack, decode and analyze the data as it arrives.

I am looking for tips / pointers. (Ideally, there is published code there, but I have not seen any "thread-friendly" examples in my search.)

Will I end up subclassing NSStream?

The ideal solution will work for devices running iOS 3.2 and later.

Thank!

+3
source share
2 answers

Ask the server (Apache?) To execute gzip in HTTP, and iOS NSURLConnection will be un-gzip as it is used. HTTP may contain binary data, so Base64 is also not needed. You should be able to get XML to access NSURLConnection as NSData, which you can use in the SAX parser (which can parse at boot).

If your server is under your control, and the server is used only by the iOS application, and performance is your main problem, you can try to send model data encoded as a binary disk. It may be easier to work with XML or JSON.

+1
source

Well, this is not the answer to the question I asked, but perhaps a “solution”.

, , , .

  • ASIHTTPRequest (Ben Copsey), XML NSXML . ASI-HTTP-REQUEST , HTTP iOS.

  • ( ) Matt Gallagher 'Base64 category, Base64 gzip.

  • gzip ASI-: NSData* xmlData = [ASIDataDecompressor uncompressData:gzippedData error:&error];, XML, .

  • , XML NSXMLParser, .

ZIP-, .txt. (, .) ZIP ; ZipKit Karl Moskowski.

, , . , 33%.:)

+1

Source: https://habr.com/ru/post/1791565/


All Articles