Behaviours: a way to simplify your application code

Lots of iOS projects end up with what we now call Massive View Controller pattern, it’s an anti-pattern of MVC, one when people end up putting 80% of application logic in ViewControllers.

This is a serious problem since View Controllers are the least reusable parts of our code, they are hard to test and maintain.

Behaviours are here to help avoid that dark scenario.

So what is a behaviour?

Behaviour is an object responsible for implementing a specific role/behaviour eg. you can have a behaviour that implements parallax animation.

Behaviours can leverage Interface Builder to limit the amount of code one can write and work more efficently with non-coders.

You could use Behaviours even if you don’t use InterfaceBuilder, and still reap most of the benefits.

Many behaviours won’t need any extra code other than setting them up, which can be done fully in interface builder or in code (some setup method). In many cases you won’t even need to have property referencing to them.

2 Videos showing example behaviours, keep in mind those actions are performed without ANY view controller code, the view controller on both videos is actually a UIViewController.