You do not pass nil
, Nil
, 0, or NULL
to didEndSelector
. Ever. You pass a selector to a method (-sheetDidClose:returnCode:contextInfo:
) that you have declared. That you are passing something other than a selector makes whatever else you're doing to dismiss the sheet suspect. (You haven't said if the panel stays on top because it's never dismissed, but that's my assumption here.)
Take a look at Using Custom Sheets, which is Apple's own documentation on the subject.
Also, be sure that the panel you are using has its "Visible At Launch" flag turned off in IB.