PDA

View Full Version : Binding WebView in Core Data app




ace2600
Apr 13, 2009, 11:44 PM
I have a basic Core Data application for an array of Jobs displayed in an NSTableView. I want to add a WebView that will load the string inside the job.htmlSummary attribute for the selected item in the table view (job is my entity). If I use an NSTextField, I can simply use "Bind To: Jobs" for Value in the bindings inspector with Model key path set to htmlSummary.

However, I have no idea how to do this for the WebView. I know the code would be something like [[webView mainFrame] loadHTMLString:selectedItem.htmlSummary baseURL:myUrl];But I do not know how to call this every time the selection changes. Or how that binding works.

P.S. I am using Hillegass's chapter on creating a Core Data document application as the inspiration. CarLot is the example.



ace2600
Apr 15, 2009, 12:06 AM
After thinking about the problem more, I'm really just after a way to be notified when the selection changes. I can load the HTML into the WebView and everything programmatically after that.

How can I run an action on every selection change in the NSTableView?

GorillaPaws
Apr 15, 2009, 12:37 AM
After thinking about the problem more, I'm really just after a way to be notified when the selection changes. I can load the HTML into the WebView and everything programmatically after that.

How can I run an action on every selection change in the NSTableView?

NSTableViewSelectionDidChangeNotification (http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSTableView_Class/Reference/Reference.html#//apple_ref/doc/uid/20000118-BCICGIJA) is what you're looking for I think.