You use functions when you have, well, a function ;-) You know the definitions: a method has an implicit argument of self and can access instance variables using this; the function has no implicit arguments - all that is needed must be passed.
If you refactor a part of a larger method, that part does not access instance variables, and you do not refactor it so that the subclass can override it, and then let Xcode build you a function. When this is done, add static to it so that it is closed to the class.
You didnβt lose anything and made it clear that a piece of code is a function - it does not change the state of an object.
Of course, there is no hard line between the choice of a function and the method, its fuzzy boundary. If a piece of code, say, simply accesses one or two instance variables, but does not update them, then you can select a function - again, it is clear that the state of the object does not change. But you do not want to pass many instance variables as parameters that are simply hard to read (and inefficient).
Using functions can be good, and of course, doing it well in Objective-C is nice.
source share