Problem with bindings

Discussion in 'Mac Programming' started by LinusR, Feb 4, 2011.

  1. LinusR macrumors regular

    LinusR

    Joined:
    Jan 3, 2011
    #1
    Hi friends,

    I have an NSArray and a binding to one column of the NSTableView via an NSArrayController. Now I binded an NSTextField to the same variable. This text field should show the content of one entry of the nsarray of the selected row in my NSTableView.
    When I try to delete one row including entry in the array with this code:

    Code:
    	filePath = [[[NSBundle mainBundle] pathForResource:@"Games" ofType:@"plist"] retain];
        NSDictionary *dict =[NSDictionary dictionaryWithObjectsAndKeys:
                             [loadTitle stringValue], @"gameTitle",
                             [loadYear stringValue], @"gameYear",
                             [loadPublisher stringValue], @"gamePublisher",
    						 [loadDescription stringValue], @"gameDescription",
    						 [loadGenre stringValue], @"gameGenre",
    						 [loadCoverPath stringValue], @"gameCoverPath",
    						 [loadLicense stringValue], @"gameLicense",
    						 [loadProgress stringValue], @"gameProgress",
    						 [loadRating stringValue], @"gameRating",
                             nil];	
    	
        [arrayTitles removeObject:dict];	
        if ( ![[NSFileManager defaultManager] fileExistsAtPath:filePath] || [[NSFileManager defaultManager] isWritableFileAtPath:filePath]) {
            [[arrayTitles arrangedObjects] writeToFile:filePath atomically:YES];
        }
    
    ... it doesn't work. When only the NSTableView was binded, the delete action worked perfectly (the controller key in the table view column is "arrangedObjects", in the textfield it is "selection"). What do I wrong?

    Thanks for any help.

    Have a nice day,

    Linus
     
  2. Sydde macrumors 68020

    Sydde

    Joined:
    Aug 17, 2009
    #2
    Try deselecting the row before you remove it?
     
  3. LinusR thread starter macrumors regular

    LinusR

    Joined:
    Jan 3, 2011
    #3
    I tried but it didn't work. I figured it out now. My problem is my NSLevelIndicator. It returns the value as double although I connected it with an NSNumberFormatter. What do I wrong?
     
  4. Sydde macrumors 68020

    Sydde

    Joined:
    Aug 17, 2009
    #4
    If the level indicator outputs a double, and the number formatter wants a NSNumber, could it be a communication problem? How would you change the type in the binding to get the right type of value sent?
     
  5. LinusR thread starter macrumors regular

    LinusR

    Joined:
    Jan 3, 2011
    #5
    I load them with a method called loadDataFromPlist: . When it gets loaded, the NSNumberFormatter works.

    I got it to work without this formatter. I used the method loadDataFromPlist: again so it gets called automatically. It's a little bit hard coding but it works.

    Thanks for your help,

    Linus
     

Share This Page