title: Autoupdating NSManagedObject property modification timestamp
body: <p>I have an <code>NSManagedObject</code> with two properties:</p>
  
  <pre><code>NSNumber *score;
  NSDate *score_timestamp;
  </code></pre>
  
  <p>I want my <code>score_timestamp</code> field to be updated each time I update <code>score</code>.</p>
  
  <p>I obviously cannot use <code>-willSave</code> method as my context is saved occasionally, and <code>score_timestamp</code> won't be up to date. So I should either override <code>-setScore:</code> or setup my managed object as a key-value observer for its own <code>score</code> field.</p>
  
  <p>The <code>-setScore:</code> solution seems easy:</p>
  
  <pre><code>- (void) setScore:(NSNumber *)score
  {
      [self willChangeValueForKey:@"score"];
      [self setPrimitiveScore:score];
      [self didChangeValueForKey:@"score"];
  
      self.score_timestamp = [NSDate date];
  }
  </code></pre>
  
  <p>Are there any caveats in doing things that way? Or I should use a KVO solution?</p>
  
  <p><strong>Update</strong></p>
  
  <p>So far I've received two responses that my code will not work through <code>setValue: forKey:</code> and I'm still waiting for example. Naive calling <code>[(NSManagedObject *)myObject setValue:value forKey:@"score"]</code> calls my setter all the same.</p>
  
  <p>So if I switch to KVO solution, should I <code>addObserver:</code> in all <code>awake</code> methods and remove it in <code>willTurnIntoFault</code>? Or that's not that simple?</p>