- . , -setEndOn: on Medication; - . , MedicationManager, . , , MedicationManager -createMedicationWithName: startOn: endOn: :
- (Medication*) createMedicationWithName:(NSString*)medName startOn:(NSDate*)startDate endOn:(NSDate*)endDate
{
Medication *newMedication = (Medication *)[NSEntityDescription insertNewObjectForEntityForName:@"Medication"
inManagedObjectContext:[self managedObjectContext]];
[newMedication setName:medName];
[newMedication setStartOn:startDate];
[newMedication setEndOn:endDate];
[newMedication addObserver:self
forKeyPath:@"endOn"
options:NSKeyValueObservingOptionNew
context:nil];
return newCompound;
}
- (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context
{
if ([keyPath isEqualToString:@"endOn"])
{
return;
}
}
- .
, Observer... , MedicationManager . , , addObserver . , "" ( -awakeFromFetch).