Constructs in Objective C and Swift

Classes, Structs and Enums are called Constructs and all three of them allow your program to store, organize or manipulate data in different ways with different capabilities.

Classes
  • General Purpose, flexible construct that becomes the building blocks of your program code.
  • Have properties and methods that provide data storage and functionality to constructs
  • Can use inheritance
  • Can use initializers and de-initializers when setup or tear down when they are created or destroyed.
Structs
  • Structs in Swift can have Properties and Methods (Swift Only)
  • Can use initializers (Swift Only)
  • No Inheritance
  • Passed by copy ( this can be advantage/disadvantage based on the needs)
Enums:
  • Way to group related elements
  • Can include functions (Swift only)
  • Can use initializers (Swift only)

No comments:

Post a Comment