From: Rupert B. <rup...@fr...> - 2005-11-11 10:20:19
|
Hi, I'm back to square one with the SimpleStickies tutorial : encoding and decoding seem to be going well, except that I get the following message while syncing : Exception occured while syncing: Note: this class is not key value coding-compliant for the key "changed" The program looks for all the "changed" entity instances to (presumably) sync them. In - (NSArray *)changedObjectsForEntityName:(NSString *)entityName { NSEnumerator *recordEnumerator = [[self valueForKey:[self keyForEntityName:entityName]] objectEnumerator]; id record; NSMutableArray *changedRecords = [NSMutableArray array]; while (record = [recordEnumerator nextObject]) { if ([record valueForKey:@"changed"] == @"YES") // this crashes [changedRecords addObject:record]; } if ([changedRecords count] == 0) return nil; return changedRecords; } the call to '[record valueForKey:@"changed"]' crashes. Now, I wonder if our calls to self.willChangeValueForKey("#{key}") in our definition of the key_wrappers def kvc_wrapper_representation(*keys) keys.each do |key| set_key = "set#{key}" set_key[3..3] = set_key[3..3].upcase class_eval <<- EOE_KVC_WRAPPER_REPRESENTATION,__FILE__,__LINE__+1 def #{key} @_representation.valueForKey("#{key}") end def #{key}=(val) self.willChangeValueForKey("#{key}") # is this working correctly ? @_representation.setValue_forKey(val, "#{key}") self.didChangeValueForKey("#{key}") end def #{set_key}(val); self.#{key}= val; end EOE_KVC_WRAPPER_REPRESENTATION self.addRubyMethod_withType("#{key}".to_sym, "v@:@") self.addRubyMethod_withType("#{set_key}:".to_sym, "v@:@") end end is working. Any ideas ? Should we maybe (re ?)define the "changed" key for Note somewhere, or is this inherited from NSManaged Object ? I once tried to implement inherited entities in an Objective-C EntityModel test, which did not work : of course, 'Entity- Relationship' modelling is an old father of object-modelling, so I am not totally surprised ... Rup |