Re: Binding to a model class
Re: Binding to a model class
- Subject: Re: Binding to a model class
- From: Fritz Anderson <email@hidden>
- Date: Fri, 30 Apr 2004 17:06:46 -0500
On 30 Apr 2004, at 2:42 PM, Don Rainwater wrote:
Definitions:
1. MyDocument - the document class
2. MyModel - a model class
3. myArray - an array, defined in MyModel to contain MyRecord objects
4. MyRecord - the data object
I'm trying to bind an NSArrayController to myArray in MyModel, ala
Vermont Recipes VRTextFieldModel class, but I'm missing something.
The contentArray for the controller is bound to File's Owner, and the
model key path is set to myArray. Attributes/Object Class Name on the
controller is set to MyRecord, and keys are defined to match the
variables in MyRecord. When I build and run, I get an error message
about the document class not complying with key-value coding.
This will work only if the object that owns the NIB (presumably an
instance of MyDocument?) -- the File's Owner -- has a direct member
named myArray, or has accessor methods for myArray. It doesn't --
myArray isn't part of a MyDocument, it's part of a MyModel.
Do you have a data member in MyDocument that points to a MyModel
object? Call that "theModel". Then the contentArray should be bound to
the File's Owner, path "theModel.myArray".
If I define myArray and it's methods (myArray, setMyArray,
insertObject:inMyArrayAtIndex, removeObjectFromMyArrayAtIndex) in the
document class, it works. But I like the idea of setting it up in a
separate model class. Do I need to implement the insert... and
remove... methods in MyDocument instead of MyModel, or am I missing
something else?
-- F
--
Fritz Anderson
Consulting Programmer
http://resume.manoverboard.org/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.