// // CocoaSensor.m // Pennyworth // // Created by Chris Karr on 4/16/08. // Copyright 2008 Chris J. Karr. All rights reserved. // #import "CocoaSensor.h" #import "Context.h" @implementation CocoaSensor - (void) awakeFromNib { [[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(log:) name:COCOA_OBSERVATION object:nil]; } - (void) log:(NSNotification *) theNote { NSDictionary * dict = [theNote userInfo]; NSString * key = [dict valueForKey:COCOA_SENSOR]; NSString * value = [dict valueForKey:COCOA_OBSERVATION_VALUE]; NSMutableDictionary * note = [NSMutableDictionary dictionary]; [note setValue:key forKey:OBSERVATION_SENSOR]; [note setValue:value forKey:OBSERVATION_OBSERVATION]; if ([dict valueForKey:COCOA_OBSERVATION_DURATION] != nil) [note setValue:[dict valueForKey:COCOA_OBSERVATION_DURATION] forKey:OBSERVATION_LIFESPAN]; [[NSNotificationCenter defaultCenter] postNotificationName:OBSERVATION_UPDATE object:self userInfo:note]; } @end