gimenete / iOS-boilerplate

iOS-app template with lots of common tasks solved
http://iosboilerplate.com/
2.76k stars 459 forks source link

Remove Image Manager and BaseViewController; Add Twitter Search Client #17

Closed mattt closed 13 years ago

mattt commented 13 years ago

Hi Alberto,

Thanks so much for choosing AFNetworking to replace ASIHTTPRequest in your iOS Boilerplate. I hope you've found it nice to work with so far.

Looking through your use of AFNetworking in the project, I have a few suggestions (with patchesI) for how to reduce and clean up the code a bit. These suggestions stem from a difference in how ASI is used as compared to AF.

  1. Remove Image Manager: Image Manager duplicates functionality of AFImageRequestOperation and UIImageView+AFNetworking. As it currently stands, it's an unnecessary middle-man that interfaces through a very similar API.
  2. Remove BaseViewController: BaseViewController is another vestige of ASI. Methods like -requestWithURL: and mutableRequestWithURL: provide little advantage over simply using the class constructors from NSURLRequest and NSMutableURLRequest. Likewise, the different request methods are sort of an anti-pattern. For single requests, those operation objects should simply use the class constructors defined in the class (e.g. AFJSONRequestOperation +JSONRequestOperationWithRequest:success:failure. For things like requesting data from the same API (like Twitter, see point 3), AFHTTPClient handles that just fine. I would strongly advise against the current use of AFNetworking in the controllers for these reasons.
  3. Add Twitter Search Client: Since several of the examples talk to the Twitter Search API, it makes sense to use AFHTTPClient, a feature of AFNetworking specifically for this purpose.

I look forward to hearing your thoughts on these changes.

gimenete commented 13 years ago

Thanks A LOT for your help, mattt.

I was keeping BaseViewController just for some short-hand methods and for keeping a shared NSOperationQueue for all requests in a ViewController. And I was keeping ImageManager because I thought it was necessary to verify AFImageCache before doing the request. But as I can see this is not necessary.

Nevertheless I have fixed a few things. See this commit: https://github.com/gimenete/iOS-boilerplate/commit/d742b82cce5b9bad6e6fe81edde873b50ae18095

Basically two things.

Thanks again. I will update the web site ASAP with these new changes.