Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

LinusR

macrumors 6502
Original poster
Jan 3, 2011
334
515
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
 
Try deselecting the row before you remove it?

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?
 
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?
 
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?

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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.