Theocacao
Leopard
Design Element
Comment on "A Quick Objective-C 2.0 Tutorial: Part II"
by Blain — Nov 04
the method setTitle: does not exist at run time,

NSManagedObjects, for better or worse, don't create setters or getters in 10.4, and looks like 10.5 either. They do it all with KVC. What it means is that, with managed objects:
// Works! movie.title = @"The Hudsucker Proxy"; // also works! [movie setValue: @"The Hudsucker Proxy" forKey: @"title"]; // Doesn't work unless you made the function. [movie setTitle: @"The Hudsucker Proxy"];

Long answer:
If you've got your heart set on setTitle:, the 10.4 way would be making the method yourself, and using setPrimativeValue:forKey:. You'd have to diddle about to verify that willChangeValueForKey: and didChangeValueForKey: were called for you or not. It's pretty messy, and there's probably a better way that I don't know.

Short answer:
Dot notation and setValue:forKey: are your friends, especially with MO.
Back to "A Quick Objective-C 2.0 Tutorial: Part II"
Design Element

Copyright © Scott Stevenson 2004-2015