chap 14 to 19 - Objective C Flashcards
NSString
a class that holds strings.
NSLog()
is an objective-C function (not a method!) the format string is actually a method of NSString.
NSArray
A class that holds a list of pointers to other objects. NSArray *datelist = [NSArray arrayWithObjects:now, tomorrow, yesterday, nil];
NSArray methods
count – returns the number of items in an array.
objectAtIndex – returns the pointer that the array has stored at the index specified argument.
fast enumeration
a type of loop that is extremely efficient way to walk through the items of an array.
for (NSDate *d in datelist){
NSLog(@”Here is a date: %d”, d);
}
MSMutableArray
similar to an instance of NSAray but you can add and remove pointers. It is a subclass of NSArray. [datelist addobject:now]; [datelist insertObject:yesterday atIndex:0];
class is defined by what two files?
Header(interface) file – contains declarations of instance varibles and methods.
implementation file – this is where you write out steps for, or implement, each method.
instance method
Begins with a dash. - (void) setDoors:(int)anInt { … }
class method
Begins with a plus. +(int) wheels {
return 4;
}
@property
initializes get and set methods. @property int doors;
self
a pointer to the object that is running the method. It is used when an object wants to send a message to itself.
inheritance
a class inherits the instance variables and methods from the parent class.
@synthesize
sets get and set methods in the implementation file. #import “Employee.h” @implementation Employee @synthesize employeeID; @end
super
the super directive says, run this method, but start the search for its implementation at my superclass.
object instance variables
points to another object and describes a relationship between two objects.