Day-1 Flashcards
NSObject
All the Classes are descendants of the root class of NSObject
The Asterisk *
Reference to variable live in the stack and usually refers to space in memory (memory address)
Init in Class
We always return instance type (Self) with every init in a class
There’s always one overarching init and we can create other designated initializers (we also call them convenience inits)
External and Static Variables
An external variable is one whose value can be accessed and changed by any other methods or functions. Inside the module that wants to access the external variable, the variable is declared in the normal fashion and the keyword extern is placed before the declaration. When dealing with external variables, you can declare a variable as extern in many places, but you can define it only once: extern int gMoveNumber;
Static variables are global but not external. In other words, you want to define a global variable to be local to a particular module (file). You might want a class method to be capable of setting and accessing variables
Typedef
It’s the alternative to TypeAliases in Swift
Categories
Categories in Objective-C are essentially extensions in Swift and used for the exact same purpose
Protocol in Objective-C
A protocol is a list of methods that is shared among classes. The methods listed in the protocol do not have corresponding implementations and you cannot extend Objective-C protocols
Swift manipulate a lot with protocols which is awesome!
- +
Class
” - “ is always an instance
“ + “ class method
without them it’s just a Class