回答

0
Try like this:- 

    #import <Cocoa/Cocoa.h> 

    @interface customHeaderCell : NSTableHeaderCell 
    { 

    } 

    @end 

    #import "customHeaderCell.h" 

    @implementation customHeaderCell 

    -(id)initTextCell:(NSString *)aString 
    { 
    if([aString isEqualToString:@"yourHeaderCell"]) 
{ 
    // do your stuff here; 
} 
     return [super initTextCell:aString]; 
    } 

    @end 


    Now in other class wherever your table view you are using write the following the code:- 

    -(IBAction)addData:(id)sender 
    { 
     for (NSTableColumn *col in [tableView tableColumns]) 
     { 
      customHeader=[[customHeaderCell alloc]initTextCell:[col identifier]]; 

     } 

    } 
+0

你能解釋一下嗎? 「我是新來的可可開發,我沒有得到」現在在其他類中,無論你使用的表視圖寫下面的代碼:「我的意思是什麼是這個addData。我不明白如何將customeHeaderCell與說我的NSTableHeaderView的子類連接?我仍然不知道如何鏈接這兩個子類 – user2085689