开发者

How to show calculated values in NSTableView?

I have an NSTableView that binds via an NSArrayController to an NSMutableArray of NSString's.

There's also a TextView in the same window. What I want to do is display a number of occurrences of each NSStr开发者_如何学Pythoning in the NSTableView.

I've thought of a way to do this, but that doesn't look elegant way of doing this:

Inherit from NSString and define new method that performs a search in predefined object (NSTextView) and returns the number of occurrences.

I'm guessing there must be a more natural way of achieving the same result?

EDIT:

Sorry, should have clarified. NSSMutableArray is an array of NSObjects that have an NSString property. I suppose I could define an extra method (findAllOccurencesOfString:inString:) which would return a number. But the question is how do I bind to this function and in that binding how to I pass a var (pointer to textField)??


You'll need to have a wordCount (read only) property on whatever objects are in your table data source, this will have to call your new method internally using the object's own string value, as you can't pass parameters in bindings (unless they've changed, I haven't used bindings for a while as I've been concentrating on iOS). Then bind to this property for the column in the table. Presumably you don't need to pass the pointer to the textfield as there is only one?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜