From: Dave H. <gr...@gr...> - 2006-01-20 22:08:55
|
On Jan 20, 2006, at 13:11, Jonathan Paisley wrote: > On 20 Jan 2006, at 20:49, Dave Howell wrote: > >> def alertDidEnd_returnCode_contextInfo(theAlert) >> return >> end >> >> Unfortunately, I can't do anything but one-button messages, because I >> can't get the return code back from the NSAlert. The call to >> 'beginSheetModalForWindow...' looks like this in Objective-C: >> >> beginSheetModalForWindow:[someWindow window] >> modalDelegate:self >> didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) >> contextInfo:nil >> >> How exactly can I get a parameterized selector into this thing? In >> other words, how do I do >> @selector(alertDidEnd:returnCode:contextInfo:) >> in RubyCocoa? > > Is your callback method being called? Your ruby method: > > def alertDidEnd_returnCode_contextInfo(theAlert) > > doesn't have the right signature, because it's supposed to take three > arguments: > > def alertDidEnd_returnCode_contextInfo(theAlert,code,context) Not according to RubyCocoa. Like I said, the code as listed works "correctly." If I change my callback method to def alertDidEnd_returnCode_contextInfo(theAlert, returnCode, contextInfo) then the entire app blows apart: rb_main.rb:22: [BUG] Bus Error Any attempt to add a second parameter to the callback method causes that result. > Does using the 'code' argument there work? > > I think you can also use symbols for selectors (instead of strings) > e.g., :alertDidEnd_returnCode_contextInfo. Don't think it makes any > difference, just a matter of choice. Well, it's a string because I was trying to get the parameters to pass properly, like 'alertDidEnd_returnCode_contextInfo:returnCode:contextInfo" or "@selector(alertDidEnd:returnCode:contextInfo" But all such guesses failed one way or the other. |