My first though was to use a find panel to go to the text I want to search.
But what I have now is better.
I have a NSTableView fill with function names and a source file path were I can see how the function is used. When I clicked on a function name, I load the source file in the NSTextView and scroll down to the funtion I want to investigate.
My only bug is when I click on a column header to sort the NSTableView,
the name of the function does not match the path name.
The TableView
is bound to an ArrayController.
Code:
- (IBAction) fOpenSourceButtonClicked: (id)sender
{
//get the row selected in the scroll view
int irow = [scrollview selectedRow];
//get the columns of the scroll view
NSArray * aColumns = [scrollview tableColumns];
//get the source path column (index = 1)
NSTableColumn * tcolpath = [aColumns objectAtIndex:1];
//get the selected cell for the source path
// BUG: DOESN'T MATCH WHAT I SEE IN THE TABLEVIEW
NSTextFieldCell * tfcell = [tcolpath dataCellForRow:irow];
//get the source path text
NSString * strPath = [tfcell stringValue];
//get the function name column (index = 0)
NSTableColumn * tcolfuncname = [aColumns objectAtIndex:0];
//get the selected cell for the function name
NSTextFieldCell * tftosearch = [tcolfuncname dataCellForRow:irow];
NSString * strToSearch = [tftosearch stringValue];
}