NSTextView data bindings losing info when saving to core data.

  • While Core Data issues are being brought up (http://www.cocoabuilder.com/archive/message/cocoa/2007/11/2/192065
    ) , I'd like to ask about something that's been bugging me.

    In tiger I would often bind the data or attributedString value from a
    NSTextView to some Core Data object in an NSArrayController, and it
    worked without a hitch. In Leopard, however, when I do the same thing,
    and hit save after entering text into the text box, the string value
    is reverted to the value from before the change.

    "Rather unpleasant" as well if you have written quite a long string!

    It works as expected when you enter the string, and then quit. The
    string is stored and saved to the persistent store.

    If you don't hit save but just change the selection in the array
    controller, the text view stores the string in the bound object
    properly, and then you are free to hit save. There's possibly a reason
    for this change in Leopard, but I don't understand it!

    I thought there might be some extra configuration, so I checked the
    Continuously Updates Value box in the TextBox, but running the app
    with this blows up

    2007-12-07 12:55:16.289 TextBoxBug[11494:10b] Cannot create NSData
    from object  of class NSCFString
    2007-12-07 12:55:16.291 TextBoxBug[11494:10b] *** Terminating app due
    to uncaught exception 'NSInternalInconsistencyException', reason:
    'Cannot create NSData from object  of class NSCFString'

    This checkbox is certainly under the data binding (as you can see in
    the demonstration app attached to this post), but it looks as though
    with the option checked the binding is forgetting to turn the string
    into data?

    So I think, well that's not it, and uncheck the box again, but it
    still blows up. The only way I can get it to work again is if I delete
    the whole TextView, add a new one, and rebind it, and then I'm back to
    square one.

    What should I be doing?

    Here is the app "TextBoxBug"

    - Mathieu Tozer
previous month december 2007 next month
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Go to today