四列NSTableView的RubyCocoa控件方法
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了四列NSTableView的RubyCocoa控件方法相关的知识,希望对你有一定的参考价值。
# What you NEED in the controller to be able to list someting in a NSTableView in RubyCocoa # # Creates the storage array, and another array which contains the names of the columns. def initialize @objects = Array.new @columns = ["Column Name 1", "Column Name 2", "Column Name 3", "Column Name 4"] end # Returns the numbers of rows in the array for NSTableView to display. def numberOfRowsInTableView(aTableView) return @objects.length end # Uses the @columns array to to enable a flexible number of columns when fetching data. def tableView_objectValueForTableColumn_row(afileTable, aTableColumn, rowIndex) @columns.each do |column| if aTableColumn.headerCell.stringValue == column object = @objects[rowIndex] return object[column] end end end # Usage: # # Creates the object that will go into the array. Mind you, the key values must be named the same way as the columns in the NSTableView, which is why it might be a good idea to use the actual @columns array post a identifiers. object = { @columns[0] => "Put...", @columns[1] => "...your...", @columns[2] => "...values...", @columns[3] => "...here" } # Adds the object to the @objects array @objects += [object] # Updates the NSTableView after a new post/row has been added to the storage array @tableViewOutlet.reloadData
以上是关于四列NSTableView的RubyCocoa控件方法的主要内容,如果未能解决你的问题,请参考以下文章
NSTableView 内的 NSTableViewCell