Fundamentals Flashcards
Learn fundamentals of Objective-C
int
storing integers - %i or %d
char
storing characters - %c
float
storing numbers with decimals - %f
double
same as float but double accuracy - %e
Counting
Always start with zero
Conditionals
For making a decision
==
equality operator check
=
For assigning the first value to the second
x++
Increase by 1 for loops
While
Like “for” but conditional runs after block of code
Pointer
Point to a location (for computer memory)
int* foo = 123
OOP
Variable and Functions trade for Objects and attributes
Objects
Are instance of a class
Instant Method
One object in a class i.e. - (void) addGas;
Class Method
All objects in class i.e. All Cars
Method syntax
[recipient message];
who method
Nested ex. [NSString alloc] init];
best practice never do more than 2
Accessor Methoods
Get data
Setter Methods
Update attributes of objects - no need to return a value
- (void) setCaption: (NSString*)input;
Data Encapsulation
Data is contained by methods in classes
Classes Contain 2 Files
Implementation (.m) and Interface (.h)
Interface File (.h)
Defines instance variables and public methods
Implementation File (.m)
Actual code for methods in interface file including private methods
NS
Next Step
NSString
String text that is immuatable