&tag(NSTableView); *目次 [#k6d41468] #contents *関連ページ [#p82e7ede] *参考情報 [#m87325d3] -[[Table View Programming Guide for Mac: About Table Views in OS X Applications:https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/TableView/Introduction/Introduction.html]]…公式ドキュメント -[[NSTableView:http://hmdt.jp/cocoaProg/AppKit/NSTableView/NSTableView.html]] -[[NSTableView にデータを表示させる方法 · rakuishi.com:http://rakuishi.com/archives/5535]] -[[objective c - (Cocoa) What's the equivalent of a UIViewController subclass in a single window cocoa app? - Stack Overflow:http://stackoverflow.com/questions/10123045/cocoa-whats-the-equivalent-of-a-uiviewcontroller-subclass-in-a-single-window]]…UIViewControllerとの違い *基本 [#z76c47e9] -view-baseとcell-baseの違いがある。 -view-baseの方が新しく、iOS的。 [[Cocoa - NSTableViewにカスタムセルを使用する - Qiita:http://qiita.com/_tid_/items/535f3c5ac385cc214d50]]によると実装しないといけないメソッドが異なる。 *超基本的な実装方法 [#md9a92a9] **概要 [#r6d714b4] -プログラムからゴリゴリつくるのではなく、Interface Builderを使う方法が基本らしい。 **データソースクラスの生成 [#ge4e9861] -UIKitの場合、UITableViewControllerを使うのが定番だけど、AppKitにはNSTableViewControllerがない(NSViewControllerはあるみたいだけど)。NSObjectを直接継承し、NSTableViewDataSourceを実装するのが定番っぽい。 -例: TableController.h @interface TableController : NSObject <NSTableViewDataSource, NSTableViewDelegate> -TableController.mに必要なメソッドは最低限以下の二つ #pre{{ - (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowInde }} - **Interface Builder上で接続 [#j53dd6e3] -Interface Builderで、Table Viewを設置。 -NSObjectを設置して、TableControllerクラスとする。 -Table Viewのデータソースを上のTableControllerに設定(IB上で)。