Hi all,

I'm re-posting this question. Hopefully more clear than before.

I've been struggling much with a problem for so long and fail to get it to work. I don't know where I go wrong but below is my code.

I've got 2 tableviews populated by this file, data.plist, with bindings. When I push a button it loads the data in the tableviews. Selecting a row from the first tableview loads the second and immediately updates the webview with the corresponding html-file. And that annoys me.

There's something about notification, tableSelectionChanged, and NSTableViewSelectionDidChangeSelection. But I'm unsure how it works. I've been reading up on the tableview class reference, but still...

I'd like so very much ...

a) ... to load the data in the tableviews one tableview at a time
or
b) ... update the webview when a row is selected in the second tableview, i.e. the final tableview.

I appreciate any help that can be provided. /Philip :-)


#pragma mark -
#pragma mark Load Data in TableViews
// Notified from the array controller that the chapter selection has changed, now update the webView - (void) observeValueForKeyPath:keyPath ofObject:(id)obj change: (NSDictionary*)change context:(void*)context {
                        
                        // Chapter dictionary and the three values needed from 
it
NSDictionary* chapter = [[obj selectedObjects] objectAtIndex:0]; // Only select 1 at a time, so -selectedObjects is an array of 1
                        NSString* directory = [chapter 
objectForKey:@"directory"];
                                                
                        // Grab the URL and load in the webView
                        NSURL *url = [NSURL fileURLWithPath:directory];
                        [[webView mainFrame] loadRequest:[NSURLRequest 
requestWithURL:url]];
                        
                        // Ensures that the first tableview does not scroll out 
of view
                        [tableView1 scrollRowToVisible:[tableView1 
selectedRow]];                       
}

-(void) tableSelectionChanged:(NSNotification*)aNote {
        NSTableView* tableThatJustChanged = [aNote object];
        if ( tableView1 == tableThatJustChanged ) {
                // Get the selection of the publicationsController
        } else if ( tableView2 == tableThatJustChanged ) {
                // middle
        }
}
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to