Fundamentals Flashcards

Learn fundamentals of Objective-C

1
Q

int

A

storing integers - %i or %d

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

char

A

storing characters - %c

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

float

A

storing numbers with decimals - %f

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

double

A

same as float but double accuracy - %e

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

Counting

A

Always start with zero

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

Conditionals

A

For making a decision

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

==

A

equality operator check

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

=

A

For assigning the first value to the second

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

x++

A

Increase by 1 for loops

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

While

A

Like “for” but conditional runs after block of code

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

Pointer

A

Point to a location (for computer memory)

int* foo = 123

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

OOP

A

Variable and Functions trade for Objects and attributes

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

Objects

A

Are instance of a class

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

Instant Method

A
One object in a class 
i.e. - (void) addGas;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Class Method

A
All objects in class
i.e. All Cars
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Method syntax

A

[recipient message];
who method
Nested ex. [NSString alloc] init];
best practice never do more than 2

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

Accessor Methoods

A

Get data

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

Setter Methods

A

Update attributes of objects - no need to return a value

- (void) setCaption: (NSString*)input;

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

Data Encapsulation

A

Data is contained by methods in classes

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

Classes Contain 2 Files

A

Implementation (.m) and Interface (.h)

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

Interface File (.h)

A

Defines instance variables and public methods

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

Implementation File (.m)

A

Actual code for methods in interface file including private methods

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

NS

A

Next Step

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

NSString

A

String text that is immuatable

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

NSMutableString

A

String that is mutable

26
Q

NSArray

A

Array of objects that is immutable

27
Q

NSMutableArray

A

Array of objects that is mutable

28
Q

NSNumber

A

Holds numeric value

29
Q

Inheritance

A

All classes inherit from parent class (ex. methods)

30
Q

@property (weak)

A

Attributes is used as a reference. Attribute is not owned by the object

31
Q

@property (strong)

A

Attribute is owned by the object and will be save in memory

32
Q

ARC

A

Automatic Reference Counting used to make memory counting easier

33
Q

NSArray

A

Holds a list of objects

34
Q

NSDictionary

A

Holds a list of key/value object pairs

35
Q

@

A

Common prefix for all Objective-C literals

36
Q

Literals

A

NSString, NSArray, NSDictionary, etc.

37
Q

Nil

A

Prints a null meaning no value

Value of an object pointer when it isn’t pointing to anything

38
Q

*

A

Pointer to where information can be found

39
Q

%p

A

Prints output

40
Q

id

A

Generic container to put in any type of object (string, array, etc,)

No need for * because id is a pointer by definition

41
Q

selector

A

SEL object to call during runtime - how you send in methods names as parameters

SEL firstNameSelector = @selector(firstName);

NSLog(@”[person firstName] = %a”, [person performSelector:@selector(firstName)]);

42
Q

enums

A

list of predefined values / constants

43
Q

structs

A

structure group of variables

44
Q

unsigned int

A

integers with no negatives %u

45
Q

void

A

Return nothing

46
Q

dot syntax

A

Only for “getter” & “setter” methods (accessor)

47
Q

method with input

A

method:input

48
Q

Class Method

A

+ (NSString*) caption;

49
Q

dealloc

A

Called on an object to remove it from memory

Use finalize method with garbage on

50
Q

reference counting

A

alloc an object, retain an object, you should release for each occurrence

51
Q

2 Reason to Create an Object

A
  1. To keep it as an instance variable

2. To use temporarily for single use inside a function

52
Q

Memory Management inside a function

A

If you create an object with alloc or copy, send it a release or autorelease. Any other way, do nothing.

53
Q

retain

A

For @property to retain input value

54
Q

@synthesize

A

Automatically generates the setter and getters for us in Implementation file
@synthesize caption;

55
Q

self.<var></var>

A

Syntax for setter method which includes memory management

56
Q

categories

A

Allows you to add methods to an existing class without subclassing it or needing to know further details. Utilities is Category.
@interface NSString (Utilities)
- (BOOL) isURL;
@end

57
Q

new line

A

/n

58
Q

Precedence

A

Parenthesis, exponents, multiplication, division, add, subtract

59
Q

Modulus

A

The remainder %
int m = 38 % 7;
return 3

60
Q

new line

A

/n

61
Q

@class

A

used when we only want to declare the object of any class..

62
Q

@interface

A
Creates a class
@interface Fraction: NSObject {
    int numerator;
    int denominator;
}