There is a
UITableViewCell subclass with a
UIButton inside. A web call should be made when the button is pressed.
The question is whether I should set the action in the controller, or can the action be set within the
UITableViewCell subclass? Will the second option violate MVC pattern?
Best How To :
The second option will certainly violate MVC pattern. ViewController works like a glue between your models, views and contains all the business logic. ViewController should receive action then make your api call and put formatted data to your views.
Usually in my project I always try to move networking code into separated set of classes which can handle fetching data from API, transforming from JSON/XML to model objects and formatting them (string date object to NSDate object etc.). Then I can call simple looking method in my ViewController and populate views/tableview cells.
On the other hand,
If you have some time you can look at MVVM which is getting more popular. There are some links (start with sprynthesis which is AWESOME):
And some sample apps:
That helped me to understand MVC more deeply thanks to comparision to MVVM.
Don't be scared with usage of ReactiveCocoa, you can always adopt MVVM without it but it's worth to look at. (It has really steep learning curve and I still feel like an idiot)
Also there is a great article about design patterns with iOS implementation:
raywenderlich design patterns