Objective-C Flashcards

1
Q

Pointers to objects come in what two flavors?

A

id and static type (UIButton)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Why wrap primitive types in an object? E.g. Double using NSNumber?

A

Because …

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are some compelling reasons for having properties?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you define properties w/o instance variables?

A

By not using @synthesize, you’re able to create custom setter and getter

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a struct?

A

A struct is a type made up of other types.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a pointer?

A

A pointer is a memory address.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is an expression?

A

An expression is something that gets evaluated and results in some value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a pointer to an object?

A
  • 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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is nonatomic?

A

This property attribute means that access to its property is

not thread-safe.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is @synthesize?

A

this makes an actual backing, an instance variable, for a @property. It also makes default getters and setters.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the default implementation of a @property?

A

@syntheize contents; // creates _contents

– (void) setContents : (NSString *) contents {
_contents = contents;
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do you specify a conditional operator? aka ternary operator?

A

Using “?” like this:

int minutesPerSec = conditionExpression ? 15 : 20

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

When do you want to use global variables?

A

When you want them available from any function in a all files

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a static variable?

A

Like a global variable, but only accessible from the file in which it was declared.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly