nstextview bindings

Discussion in 'Mac Programming' started by MrFusion, Aug 14, 2006.

  1. macrumors 6502a

    Joined:
    Jun 8, 2005
    Location:
    West-Europe
    #1
    I have a NSTextView that is binded with coredata. When text is entered, it is not always passed on to the backend when the user does something else. This results in the loss of the data entered. Is there someway to force the nstextview to save the data every time it's changed by the user, without having to resort to delegate methods and manually updating the nsmanagedobject? That would nullify the idea behind bindings, or not.
     
  2. macrumors 68030

    slooksterPSV

    Joined:
    Apr 17, 2004
    Location:
    Nowheresville
    #2
    Personally, it sounds like you don't have it binded correctly then. Cause any data you add or remove should stay there. That's just my thought on it...

    EDIT: You just helped me out with my app, thanks, here's a screenshot of it:
     

    Attached Files:

  3. thread starter macrumors 6502a

    Joined:
    Jun 8, 2005
    Location:
    West-Europe
    #3
    You're welcome. :)
     
  4. Guest

    caveman_uk

    Joined:
    Feb 17, 2003
    Location:
    Hitchin, Herts, UK
    #4
    Is it only saving the data when you tab away from the text view? If so, you need to check the 'continuously updates value' checkbox.
     
  5. macrumors 68030

    slooksterPSV

    Joined:
    Apr 17, 2004
    Location:
    Nowheresville
    #5
    Actually, that just duplicates the value's in the textview - at least it did for me. - What's its type? Is it Binary Data? It has to be Binary Data for it to work.

    Other q?s = is it Document-based? Is it based on a selection for the text? e.g. a table selection.
     
  6. Guest

    caveman_uk

    Joined:
    Feb 17, 2003
    Location:
    Hitchin, Herts, UK
    #6
    My textviews were bound to objects in a dictionary (so not core data) and checking that box made sure the users edits were saved (otherwise the edits are not recorded unless the user moves the focus to another control)
     
  7. macrumors 68030

    slooksterPSV

    Joined:
    Apr 17, 2004
    Location:
    Nowheresville
    #7
    See that's how mine works.

    That has me think of another question - what are the actions to produce the result:
    e.g. User types in box, user clicks on a different application, user changes a property in an NSSheet, user goes back to data and data is gone.

    Give us the exact steps, that'll help us out.
     
  8. thread starter macrumors 6502a

    Joined:
    Jun 8, 2005
    Location:
    West-Europe
    #8
    I found a fix for it. But this is what happend:
    I have two views, with a button to switch between them. This is done with addsubview and removefromsuperview.

    The textview was in one of the views. When the user types in text and then clicks on the switch button (the focus is still on the textview) the typed in text is lost. When the user first clicks somewhere else, the text is saved.

    I solved it by adding these lines before I switch from the view with the textview to the view without it.

    [[myArrayController selection] setvalue:[[[myTextview stringvalue] copy] autorelease] forkey:mad:"theText"];

    Without the copy the text doesn't get retained, and without the autorelease it leaks.

    Yes, the bindings are fine, and the 'cont. update' is also checked.

    Thanks for the replies.
     

Share This Page