Trying to work out the correct syntax but getting “Invalid Overload”
method DetailView.DoclickClose;
begin
(parentViewController as UINavigationController).popViewControllerAnimated(true);
end;
method DetailView.init: instancetype;
var
ACloseButton: UIBarButtonItem;
begin
inherited;
title := 'My Detail View'
ACloseButton := new UIBarButtonItem withTitle('Close') style(UIBarButtonItemStyle.Plain) target(nil) action(DoclickClose);
end;
ACloseButton := new UIBarButtonItem withTitle('Close') style(UIBarButtonItemStyle.Plain) target(nil) action(DoclickClose);
// H3 parameter 4 is "Void" should be "SEL"
// E407 No overloaded constructor with these parameters for type "UIBarButtonItem", best matching overload is "constructor withTitle(title: NSString) style(style: UIBarButtonItemStyle) target(target: id) action(action: SEL): instancetype"
with the H3 hint indicating what the exact problem is. you will want to pass selector(DoclickClose), because the way you write it you are callingDoclickClose and passing the result (which the method doesn’t have ;), but a selector (type SEL) is expected instead.
Full call:
ACloseButton := new UIBarButtonItem withTitle('Close') style(UIBarButtonItemStyle.Plain) target(nil) action(selector(DoclickClose));
Unrelated tip, instead of method DetailView.init: instancetype;, just use Co structure syntax:
constructor DetailView;
begin
...
end;
both work, but the latter is so much nicer (and cross-platform).
I haven’t tested yet but I think my mistake was just looking at the inline error message. I’m guessing more information is given in the build log… I’ll make sure I check this in future.
Options-Cmd-Left/RIght lets you toggle between the different messages on a line, if there’s more than one. I’ll look at options for improving how they show.