the root class. Class hierarchy for a UILabel Cocoa object NSObject -> UIResponder -> UIView -> UILabel Everything in cocoa touch descends from NSObject. All cocoa objects are related to NSObject. Car is not part of the cocoa touch framework, so it’s a new base object.
-> UIView -> UILabel These last 3 are what you’ll be working with most of the time. You’ll also spend some time with AppDelegate. UIResponder and UIWindow, not so much.
that methods with the same name but different owners can do different things. A Car object and a House object both have a numberOfDoors public property but the runtime doesn’t get confused.
like isKindOfClass, isMemberOfClass, respondsToSelector, etc. These methods reveal meta info about the object - different from most methods that reveal and manipulate program data or properties.
that acts on behalf of another object when the first object encounters an event in a program.” The delegate pattern so important and popular in Apple land that we’ll be using it and referring back to it throughout the course.
structs are more powerful and do many things that Swift objects do. Some diffs... Do not support inheritance. Are pass-by-value instead of pass-by-reference. Are a bit faster because objects are dynamically allocated. Have a larger memory footprint because new memory is used on assignment.
inside of a function has a retain count of 1 until that function returns. Objects that are properties have a retain count of 1 by default. For each owner that an object has, its retain count in incremented by 1.
- compiler declaration that our property is mutable. strong - increments this pointer’s retain count by one. Swift objects are strong by default. weak - does not increment this pointer’s retain count by one. <String> - indicates that the elements in the array are of type String. Think of angle brackets as ‘must contain, must be, must conform to’ ? - indicates that carA is an optional property, so it’s nil until it’s initialized. ! - indicates that arrayA is an unwrapped optional, so you’re guaranteeing that it’s not nil. By placing the exclamation mark in the declaration, you don’t have to place it everytime you use arrayA.
you are responsible for making sure it’s initialized. At this point the reference counts of arrayA and carA are still 0 because they’re nil. The view was loaded into memory and arrayA immediately initialized. Now it’s reference count is 1.