NSAlert what should I pass?

I have an NSAlert and I call the following function to display it:


its beginSheetModalForWindow:homeWindow completionHandler:(what does go here!?)

I really don’t know what to pass to the parameter “completionHandler:”

Any help?

Thanks in advance!

You can’t use that method in ASObjC – it requires a block.

So, can I create that method in Swift and then call it from ASObjC?

You could use beginSheetModalForWindow:modalDelegate:didEndSelector:contextInfo:
It’s deprecated, but it still works

No, but you could do it Objective-C, which is what Myriad Helpers does. As Stefan says, you can also use beginSheetModalForWindow:modalDelegate:didEndSelector:contextInfo:, as long as you don’t need to run under 10.6.

You should also go to bugreport.apple.com and lodge a request for a way to call methods that use blocks from ASObjC.

I used that method, which looks like this


its beginSheetModalForWindow:homeWindow modalDelegate:me didEndSelector:"setUpWork:buttonReturned:contextInfo:" contextInfo:(missing value)

But as soon as I click on any button of the alert, the application crashes, reporting an EXC_BAD_ACCESS error.
Before I used only “setUpWork:” as selector and worked, but since I noticed that the “Cancel” button worked the same way as the “Continue” button, I changed the selector.

The method called is this


on setUpWork:alert buttonReturned:button contextInfo:info
--something
end setUpWork:buttonReturned:contextInfo:

Then you were very lucky – it should not have.

Why? It takes only the parameter “alert”, so how can I take the other two parameters?

I’m not sure what you’re asking. Are you saying you get a crash with “setUpWork:buttonReturned:contextInfo:”?

Stefan,

Have you tried it in 10.10? It looks to me like it’s broken from ASObjC (again).

It still works in Objective-C, which means Myriad Helpers will still work. I guess sooner or later I need to look at changing it to beginSheetModalForWindow:completionHandler:, but that’s only 10.9 and above.

I was asking how to put a selector which takes parameters, but doesn’t matter, I resolved using Myriad Helpers.