Streaming JSON with AFNetworking on IOS
What would be the most elegant way to receive data from a streaming JSON API using AFNetworking? AFNetworking provides excellent support for receiving non-streaming data from JSON APIs, but I couldn’t find any examples of streaming JSON.
- Calling web services with the help of AFNetworking in Objective C
- AFnetworking 2.2.0 upload image on server issues
- AFOAuth2Client and refresh token
- Swift Alamofire VS AFNetworking
- How to re-add operations when they fail using enqueueBatchOfHTTPRequestOperations from AFNetworking
- AFNetworking Form Request (Multiple File uploads in One Request)
Solutions Collect From Internet About “Streaming JSON with AFNetworking on IOS”
AFNetworking does not have a built-in streaming SAX-style JSON operation, but it should be straight forward to create your own.
- Create a subclass of
- Use the
outputStreamproperty of the operation during initialization to hook it up to a JSON parser that supports SAX-style parsing (such as Yajl). The parser will read data and build up the JSON object as it comes in
- Hook up the
responseJSONproperty to read the cached object from the parser
- …or depending on how you’re doing streaming, you may need to add a new property that defines a block to execute when new JSON objects come back (e.g.
setReceivedJSONBlock:((^)(void (id JSON))block). This block will probably be triggered by delegate methods sent from the parser (e.g.
If you are able to get this working, I would encourage you to publish and share this with others. I think this could be useful to quite a few people.
- how to pass an string value in url in iphone app
- How to transition from UICollectionView to UIViewController like Pinterest/Evernote
- Playing stream with bad internet in AVPlayer
- Background GCM Push Notification Not Received on Certain Apple Devices
- How do chat iOS applications communicate?
- Get file size in Swift
- Why is my Swift loop failing with error “Can't form range with end < start”?
- set UITextField as non editable – Objective C
- Swift class does not conform to Objective-C protocol with error handling
- difference between AudioQueue time and AudioQueue Device time
- Best Practice for NSUserDefaults synchronize
- Pass data from Parse tableview to WatchKit
- Developing for iOS on multiple computers, testing on a single device, advice?
- library not found for -lPods
- Link to local files (cdvfile://) on iOS PhoneGap 3.3