Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

stadidas

macrumors regular
Original poster
Feb 27, 2006
243
0
Kent, United Kingdom
I've looked at this code for launching a custom sheet from Apple:
Code:
if (!myCustomSheet) 
        [NSBundle loadNibNamed: @"MyCustomSheet" owner: self];

    [NSApp beginSheet: myCustomSheet 
            modalForWindow: window 
            modalDelegate: self 
            didEndSelector: @selector(didEndSheet:returnCode:contextInfo:) 
            contextInfo: nil];

I'm trying to use this code in MyDocument.m, but I don't know what to pass for the modalForWindow parameter. Everything I try gets an error. Does anyone know what to pass it to get a sheet to load in the MyDocument window?
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
If you're calling it from your NSDocument subclass (MyDocument by default), you can use the windowForSheet method.
 

HiRez

macrumors 603
Jan 6, 2004
6,265
2,629
Western US
First of all, what is the error you're getting? And how do you know that it's the "modalForWindow" parameter that's causing the error? Also, what class are you calling it from (and what superclasses)? And from what method? For example, is "window" a valid object? It won't be if awakeFromNib:/windowDidLoadNib: has not been called, or if that outlet hasn't been connected to a window in IB.
 

caveman_uk

Guest
Feb 17, 2003
2,390
1
Hitchin, Herts, UK
It depends what your controller object is a subclass of. Is 'window' defined? Maybe [self window] would work better if it is? If it isn't, define an IBOutlet NSWindow* in your code and connect it in IB to the parent window in IB.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.