It’s deprecated now that the idiots in the Twitterverse pissed off Ben, but I use ASIHTTPREQUEST and it works great. It uses NSOperations to spawn async requests and returns back all you need.
I took it sone step further, I created a SyncServer class that I instantiate for each request. It sets up ASI, fires off the Async request, receives the data, parses it and then returns to the caller the fully populated Model Class from the JSON that was returned from the request. Same as sending stuff back to the server. I just fill the model, and call SyncServer to send the JSON back to the server using ASI. Same for retrieving images, jpegs, etc. I have a single call, like this in the method that wants an image.
[sometingFrame setImage:(UIImage *)[imageCache imageForKey:[entity serialSomethingImage] type:@“Something”]]; (Words changed for modesty)
[ul][li]imageCache comes mostly right from the BNR book that checks to see if I have that image named [entity serialSomethingImage] in the cache, if so it returns it.
[li]If not in the cache it then checks CoreData to see if I have a CDObject Blog image (transformable) for that image.
I keep images less than 150k in CoreData cause they are really small and easy to get to.
[li]If not in Coredata then it checks the file system to see if a file (larger than 150k) is on the iPhone/iPad.
[li]If not in the file system then it instantiates an instance of SyncServer and puts out an HTTP GET request to download the image Async from the server.
Once it get’s the image, it will either put it on the disk or in CoreData depending on it’s size, add it to the imageCache and then return the UIImage to the caller. [/li][/ul]
So from then on it’s in the cache which I release on ‘willEnterBackground’ or if I get a memory warning.