Objective-C Basics Flashcards
Interpolate Most Basic
(@”%@”, @”Ari”);
Interpolate Most Basic Print To Command Line
NSLog(@”%@”, @”Ari”);
primatives
NSInteger
NSUInteger
CGFloat
BOOL
primitives vs objects
objects hold values and can change them through behaviors called “methods”, while primitives just hold a value.
NSUInteger
An integer value that can only be zero or positive (the “U” means “unsigned”).
0,1,2,3,4
NSInteger Format Specifier
%li
NSUInteger Format Specifier
%lu
CGFloat Format Specifier
%f or %.nf, where n is the number of decimal places to display
BOOL Format Specifier
%d
Help -> Documentation and API Reference
⇧⌘0
what is “calling a method”
its simply using a method [object method]
standard method call syntax
ReturnType *captureVariable = [recipientObject methodNameArgument:argumentVariable];
multiple method call syntax example
NSString *shorthandWelcome = [welcome stringByReplacingOccurrencesOfString:stringToReplace withString:replacementString];
has prefix has suffix example
NSString *lafayette =
@”Marquis Marie-Joseph Paul Yves Roch Gilbert du Motier de Lafayette”;
BOOL isMarquis = [lafayette hasPrefix:@”Marquis”];
BOOL isLafayette = [lafayette hasSuffix:@”Lafayette”];
if (isMarquis && isLafayette) {
NSLog(@”Ladies and gentlemen, the Marquis de Lafayette”);
}
stringByAppendingString Example
NSString *welcome = @”Welcome to “;
welcome = [welcome stringByAppendingString:@”the Flatiron School!”];
NSLog(@”%@”, welcome);