I came a cross a very nice calculator tutorial for Objective C/iOS. I have thought about this for a long time myself as well and was surprised they way it was implemented. It's very nice and elegant.
The tutorial first sets up calculatorbrain.h and calculatorbrain.m files that are meant to keep track of the calculator stack plus methods handling operations on that stack.
Then it declares a @property instance variable of that calculatorbrain class for the viewcontroller.
My questions is there seems to be a lot of ways to implement this. Why would this way be better?
1) A simple alternative would seem to be just to declare stack and stack methods within the view controller. 2) Instead of declaring it as a @property, why not just create an instance of the calculatorbrain within the view controller.
What are the advantages and disadvantages of the three ways? Which objective programming principle would provide a guideline in choosing which way is preferable?
Thanks.