Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save fernandojinzenji/afb8a83b4daa6be9f2b235abedbc9f73 to your computer and use it in GitHub Desktop.
Save fernandojinzenji/afb8a83b4daa6be9f2b235abedbc9f73 to your computer and use it in GitHub Desktop.
Week 2, Saturday - Readings and questions
Question 1
a) MVC - Model View Controller, where Model represents the data, the View represents the interface to display that data and/or
send user inputs to the Controller, and the Controller is responsible to provide Model data for the view and interpret user
actions from the view.
b) i. doctor can have many patients. - MODEL, where a Doctor object can have a property with a collection of Patients objects.
ii. A doctor should be able to see a list of all his/her patients. - VIEW, a system feature to capture these data from the
model.
iii. When looking at a patient's file, we should have the patient's picture in the top left hand corner. - VIEW, an image
representing patient's picture is the interface for the user.
iv. A doctor should be able to sort his/her patient list by last name, or by date of last visit. - CONTROLLER, get information
from a model (in this case, the patient' collection in a doctor object) and perform the sort before sending to the view.
Question 2
- (id)initWithCapacity:(int)capacity
{
self = [super init];
if (self != nil)
{
dictionary = [[NSMutableDictionary alloc] initWithCapacity:capacity];
array = [[NSMutableArray alloc] initWithCapacity:capacity];
}
return self;
}
- (void)setObject:(id)object forKey:(id)key
{
if (![dictionary objectForKey:key])
{
[array addObject:key];
}
[dictionary setObject:object forKey:key];
}
- (void)removeObjectForKey:(id)key
{
[dictionary removeObjectForKey:key];
[array removeObject:key];
}
- (int)count
{
return [dictionary count];
}
- (id)objectForKey:(id)key
{
return [dictionary objectForKey:key];
}
- (NSEnumerator *)keyEnumerator
{
return [array objectEnumerator];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment