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: Julian Dreißig <email@hidden>
- Date: Mon, 28 Mar 2005 11:03:03 +0200
Am 28.03.2005 um 02:06 schrieb mmalcolm crawford:
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:
Sorry, why is it wrong what I do? The reference tells me that binding
is supposed to be "automatically synchronizing views when models
change".
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).
I observed this behaviour even without bindings, as the above example
shows.
I did not find any documentation on binding a file wrapper either, but
I simply tried it and it works. Well, it displays the contents, but
only once. But this seems to be a problem/feature of NSFileWrapper, see
above.
Has anybody a solution to this problem?
Bind to something that is KVO compliant.
This may be a stupid question, but will it work if I wrap the
NSFileWrapper into a self-defined KVO compliant object? How does the
controller get notified about changes to the file?
- Julian
_______________________________________________
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