Re: Possible to bind file contents to a view?
Re: Possible to bind file contents to a view?
- Subject: Re: Possible to bind file contents to a view?
- From: mmalcolm crawford <email@hidden>
- Date: Sun, 27 Mar 2005 16:06:09 -0800
On Mar 27, 2005, at 11:21 AM, Julian Dreißig wrote:
is it possible to bind the contents of a (text) file to a
NSTextView? I would like to have a window which reflects the
current contents of a text file (a log file).
You're thinking about bindings backwards. You bind an attribute of a
view to a controller or model object. This misconception leads yo
astray here:
I tried it with a NSFileWrapper, binding its -regularFileContents
to the NSTextView. And yes, the view shows the contents of the file
but does not update on changes to the file, even with "updates
continually" set.
"Updates continuously" affects what changes are propagated from the
user interface to the model, see:
<http://developer.apple.com/documentation/Cocoa/Reference/
CocoaBindingsRef/Concepts/BindingsOptions.html#//apple_ref/doc/uid/
20002304/187448>
It is up to the user interface to respond to changes in the model
through KVO.
I also tried to load the file with a NSFileWrapper and -
initWithPath: and displayed its contents using -
regularFileContents. When I do some changes to the text file and
then try to update with -updateFromPath:, -regularFileContents does
not reflect changes made to the file. I have to release the wrapper
and create a new one.
regularFileContents is not KVO compliant (certainly insofar as I can
tell, and there's nothing in the documentation to suggest it is).
Has anybody a solution to this problem?
Bind to something that is KVO compliant.
mmalc
_______________________________________________
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