Objective-C Flashcards
Pointers to objects come in what two flavors?
id and static type (UIButton)
Why wrap primitive types in an object? E.g. Double using NSNumber?
Because …
What are some compelling reasons for having properties?
1) They are used for safety and subclassibilty of instance variables 2) They provide a “valve” for lazy instantiation, UI updating, consistency checking, etc
How do you define properties w/o instance variables?
By not using @synthesize, you’re able to create custom setter and getter
What is a struct?
A struct is a type made up of other types.
What is a pointer?
A pointer is a memory address.
What is an expression?
An expression is something that gets evaluated and results in some value.
What is a pointer to an object?
- This is represented by an asterick (*) and means an actual memory address for some object.
- A way to classify all Objective-C classes, because they all use the heap for memory allocation.
What is nonatomic?
This property attribute means that access to its property is
not thread-safe.
What is @synthesize?
this makes an actual backing, an instance variable, for a @property. It also makes default getters and setters.
What is the default implementation of a @property?
@syntheize contents; // creates _contents
– (void) setContents : (NSString *) contents {
_contents = contents;
}
How do you specify a conditional operator? aka ternary operator?
Using “?” like this:
int minutesPerSec = conditionExpression ? 15 : 20
When do you want to use global variables?
When you want them available from any function in a all files
What is a static variable?
Like a global variable, but only accessible from the file in which it was declared.