Re: key value observing stops
Re: key value observing stops
- Subject: Re: key value observing stops
- From: Francisco Tolmasky <email@hidden>
- Date: Tue, 24 Feb 2004 11:28:48 -0800
Actually I do want setNeedsDisplay, since each cell's object value
remains the same, it's just internal data within each object that
changes. My custom NSCell basically draws three strings, each of the
strings is a value held by the cell's object value. Thus, when I
change the value of the object (for example by saying [theObject
setObject: @"new string" forKey: WellKnownKey]) all I need to do is say
setNeedsDisplay: YES for the information to be redisplayed. I don't
want to reloadData since this would also probably rearrange the objects
(according to the sort descriptors) and I want the cell to remain fixed
in place until editing is complete, not bouncing around as you type.
The text view is being used much in the same fashion as in address
book, which is why it sets specific values of my model class. When
text is changed in a certain region of the text view, that text is
updated in the model. Something like [[model setObject: [self string]
substringWithRange: calculatedRange forKey: [[self textStorage]
attribute: keyName atIndex: calculatedRange.location effectiveRange:
NULL]]; Thus changing text in different areas changes different
attributes of my model class. If these attributes happen to be ones
that are displayed by the cell class, then I want the table to
redisplay it with the updated value.
I hope that's a little clearer, it's kind of hard explaining it all.
Thanks!
Francisco Tolmasky
email@hidden
http://users.adelphia.net/~ftolmasky
On Feb 24, 2004, at 8:19 AM, Allan Odgaard wrote:
On 24. Feb 2004, at 16:50, Francisco Tolmasky wrote:
Please configure Mail to send letters as plain text -- I prefer to
read code in monospaced font after own choosing, which I do not get
when you send letters in rich text! :)
The array controller holds instances of my modelClass. I have a
custom NSCell being used by my table view subclass and all I want to
happen is that whenever the text field changes the model, for the
cell to update to show changes. [...]
The problem may be that you invoke setNeedsDisplay: on the table view.
This will redraw the table view, but it may not fetch new values from
the data source, and so nothing will change -- I assume you wanted to
send reloadData!?!
I am not sure I understand your design though, if I do then I would
suggest something on the line of:
In the text view subclass you only invoke
will/didChangeValueForKey:@"contents" and then you add a method (named
contents) to return the text that you would otherwise pass to the
model.
In your controller setup code you then do something like:
[textView bind:@"contents"
toObject:controller
withKeyPath:@"changedText"
options:nil];
That way, each time the text changes, the system will send
setChangedText: to your controller, with the text as argument.
So you implement that method to a) pass on the text to the model and
b) invoke reloadData on the table view.
The model should not need to send any will/didChangeValueForKey:
messages.
_______________________________________________
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.