Re: Simple binding not working
Re: Simple binding not working
- Subject: Re: Simple binding not working
- From: Ken Tozier <email@hidden>
- Date: Sat, 9 Apr 2005 22:00:08 -0400
On Apr 9, 2005, at 9:34 PM, Fritz Anderson wrote:
You say you are instantiating your model object in your NIB file, and
connecting the controller's content outlet to it in IB (by
control-dragging, presumably, and not option-dragging).
Yes, I think.
The bindings tutorial instructs you to create a model object in IB by
subclassing NSObject, exporting the files, yadda, yadda, then after
adding the appropriate properties in Xcode, choosing the "Read xxx.h"
under the "Classes" menu to synchronize it.
I already had a complex model class written so used the "Import file"
command under IB's "Classes" menu instead. Once IB imported the file, I
ran the "Instantiate" menu command in IB's "Classes" menu to have
something to connect to in the "Instances" panel.
You say you are updating the fileName property of an instance of your
model class in your code.
Yes. I verified that the property is updating by sandwiching it between
two "NSLog" commands. It appears to be updating correctly in the model.
What are you doing to ensure that the instance you update is the same
as the instance from your NIB?
If I'm understanding the purpose it IB's "Instantiate xxx" menu
command, it just creates an icon you can work with for linking
purposes, not an actual independent instance. Is that right?
I only create instances at run time in response to device connected
notifications and dispose of them when the downloads are complete s
there shouldn't be multiple versions of the model floating around.
Ken
-- F
On 9 Apr 2005, at 7:36 PM, Ken Tozier wrote:
Here's what I did:
1. Defined a "fileName" property in my model class
2. Imported the model class into Interfacebuilder
3. Instantiated the model class
4. dragged an NSObjectController into the IB project and added a
"fileName" property in my model class as an NSString with the key
*fileName" in the attributes pane.
5. Option dragged from the NSObjectController to the Model instance
and clicked the connect button
6. Opened the "Download" window, selected the text field that holds
the file name and connected it to the NSObjectController in the
bindings panel. like so.
Bind To: NSObjectController
Controller Key: selection
Model Key Path: fileName
7. Saved the IB file
8. Saved the Xcode project and rebuilt it
9. Ran the project
Result:
The window opens but the file name field is empty and stays that way
even though I can see through NSLogs that the file name is getting
periodically updated.
I made sure (as per the documentation) to only change the fileName
field in my model object using the "setFileName" method rather than
directly. So the change should automatically register. No?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden