concept logic in category ios

appears as: logic, logic
Objective-C Fundamentals

This is an excerpt from Manning's book Objective-C Fundamentals.

Most of the logic in the CoinTossViewController.m file is contained in the simulateCoinToss: method, which is called whenever the user wants the result of a new coin toss. The first line simulates a coin toss by generating a random number between 0 and 1 to represent heads and tails respectively. The result is stored in a variable called coinLandedOnHeads.

  • Code reuse— A subclass inherits all the data and logic defined by its superclass (ancestor). This avoids duplicating identical code in the definition of similar classes.
  • Specialization— A subclass can append additional data or logic and/or override existing behavior provided by the superclass.