I'd like to create a WebView's WebFrameLoadDelegate's method in Delphi for this obj-c method:
- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
How should this method be declared in delphi?
These don't work:
public
procedure didFinishLoadForm( webView:WebView; Sender:WebFrame ); cdecl;
procedure webViewdidFinishLoadForm( webView:WebView; Sender:WebFrame ); cdecl;
Setting the delegate class seems to be OK using webview.setFrameLoadDelegate( d.GetObjectID );
Where d is TMyWebViewDelegate( TOCObject ) class, with GetObjectiveClass overridden, returning an interface(NSObject), like for the toolbar delegate here http://delphihaven.wordpress.com/2012/07/15/using-the-cocoa-toolbar-nstoolbar-in-xe2/
But my method is not called. What's the pattern for declaring such obj-c methods?
Usually it is best to use the exact names of the methods and parameters (as answered by Rudy). But sometimes this is not possible. Two functions might need to have the same name, but have identical parameter types so that overload
cannot be used. In that case you can use the MethodName
attribute. So here's another valid solution:
[MethodName('webView:didFinishLoadForFrame:')]
procedure webViewdidFinishLoadForm( Sender:WebView; Frame:WebFrame ); cdecl;
The correct syntax to implement the routine would be:
procedure webView(sender: WebView; didFinishLoadForFrame: WebFrame);
The name of the Objective-C selector is webView:didFinishLoadForFrame:
. The first part must become the exact name of the method, the following parts must become the exact names of the parameters (case sensitive, because Objective-C is case sensitive). That is how Delphi maps method names to selectors.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With