English 中文(简体)
Table view not updating according to bindings - Part Two
原标题:

Title borrowed from this question, of which this one is not a duplicate. See my answer there for what was wrong for that questioner; I m the author of that answer, and my problem is not that one.

I have a table view with three columns, whose Value bindings are bound to three properties of the arrangedObjects of an array controller. The array controller s contentArray is bound to the visitationResults of my document object; the items in that array are instances of a model class (VisitationResult). I have also bound the array controller s selectionIndexes and sortDescriptors to properties of my document.

I am mutating my property through a couple of accessors:

- (void) addVisitationResult:(VisitationResult *)newVisitationResult {
    [self insertObject:newVisitationResult inVisitationResultsAtIndex:[self countOfVisitationResults]];
    NSLog(@"arrayController arrangedObjects: %@", [arrayController arrangedObjects]);
}

That NSLog statement runs, and confirms that the array controller is gathering and arranging my model objects. This means that I am going through my property and getting KVO notifications for my document (which proves that the earlier questioner s problem, that of bypassing the property, is not the problem I m having).

I added NSLog statements in my model object class s accessor methods. One of them is being called—by the array controller, in order to sort the objects (that property is the sort key). The other two, which the array controller doesn t know about, never get called.

Thus, my table view remains blank.

最佳回答

I found the problem: It s because I had explicitly bound the selectionIndexes and sortDescriptors bindings of the table view.

This wasn t necessary, anyway: I just checked, and the documentation says:

selectionIndexes

Typically, selectionIndexes is bound automatically to the NSArrayController that the first NSTableColumn is bound to.

sortDescriptors

Typically this binding is created automatically, binding to the sort descriptors of the NSArrayController of the initially bound NSTableColumn.

It appears that not only is it not necessary, but binding either or both of these two will break the table view.

问题回答

暂无回答




相关问题
2 mysql instances in MAC

i recently switched to mac. first and foremost i installed xampp. then for django-python-mysql connectivity, i "somehow" ended up installing a seperate MySQL. now the seperate mysql installation is ...

Iterating over string/strlen with umlauted characters

This is a follow-up to my previous question . I succeeded in implementing the algorithm for checking umlauted characters. The next problem comes from iterating over all characters in a string. I do ...

Controlling OSX windows

I m trying to control windows of a foreign OSX applications from my application. I d like to 1. move the windows on the screen 2. resize the windows on the screen 3. change the currently active window ...

Switching J2SE versions on Mac OS (SnowLeopard)

My current JDK on Mac OS (10.6) is set to 1.6 and I d like to switch to 1.5. A listing of /System/Library/Frameworks/JavaVM.framework/Versions/ shows: lrwxr-xr-x 1 root wheel 10 Nov 3 18:34 ...

Scrolling inside Vim in Mac s Terminal

I ve been googling around trying to figure out if it s possible to use my mouse wheel to scroll while inside Vim in Mac s Terminal, with no luck. It seems as if only X11 or iTerm support this. Before ...

export to MP3 from quicktime API

A question for Apple,QT programmers. Would like to know if it s possible to export a Movie object to MP3 using the QuickTime API. Preferably the ConvertMovieToFile function. I ve looked at ...

热门标签