I’m seeking suggestions for migrating legacy code from ASIHTTPRequest to NSURLSession in Objective-C on iOS. The legacy code is one huge method with many return statements, but I would like something more modern with fewer return statements and small methods. As the title states, the backend is CouchDB; documents are keyed by uuid.
There are five use cases:
- GET UUID for a post to create a unique payload id
- PUT JSON payload using the UUID
- GET _rev for UUID (required for follow-on payload updates)
- PUT JSON payload using UUID and _rev, again for updates
- PUT a set of image(s) using UUID and _rev
Is there a common idiom for cascading requests when there are dependencies. For example, item 3 depends upon item 2 which in-turn depends upon item 1?
Thanks in advance for your suggestions.