3

I am making an app and I have to make api calls often so I was wondering which is better and why?

I am making a different class for my api calls as it makes my code much more readable and neat but Im not sure if its a good thing to do!

I am using alamofire to make all of the API calls.

Persian
  • 294
  • 2
  • 10
  • Use completion handlers. It will require less code than delegation and make the code more readable than delegate pattern. In case of delegate pattern you have to set protocol within your classes. – Gagan_iOS Sep 21 '17 at 17:03
  • @Gagan_iOS yes I think a completion handler is much better and requires less code but is that the only reason? Would there be any performance differences? – Persian Sep 21 '17 at 17:06
  • please look into following links 1. https://stackoverflow.com/questions/40412179/ios-swift-closures-callbacks-versus-delegates-when-to-use-which 2. https://stackoverflow.com/questions/15597601/delegate-function-vs-callback-function 3. https://stackoverflow.com/questions/39609727/difference-between-completion-handler-and-blocks-ios – Gagan_iOS Sep 21 '17 at 17:09

0 Answers0