NSOutlineViewDelegate プロトコル

NSOutlineView 関連のプロトコルでは、DataSource の方は存在感があるが Delegate の影は薄い。

まあ、DataSource の方はないと表示すらできないわけだが…。

試しに

@interface OutlineviewManager : NSObject<NSOutlineViewDataSource>

@interface OutlineviewManager : NSObject<NSOutlineViewDataSource, NSOutlineViewDelegate>

としてもコンパイル自体はできる。

行選択時の機能

公式ページを見るに、行選択をした時のメソッドを供給しているようです。

- (BOOL)outlineView:(NSOutlineView *)outlineView shouldSelectItem:(id)item;

のメソッドは、公式の説明だと item が選択できるかどうかを定義するもののように紹介されていますが、おそらく機能も提供できます。
OutlineView に Person クラス(のインスタンス)を表示させているとき

- (BOOL)outlineView:(NSOutlineView *)outlineView shouldSelectItem:(id)item
{
Person *p = item;
NSLog(@"%@", p.name);

return YES;
}

を実装しておくと name プロパティの値(文字列)を表示してくれます。

 

クリックclose

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です