开发者

ObjectiveC modal dialog. There is something I am missing with the class interaction

In the following code (from Apple example pages)

- (void)showCustomDialog: (NSWindow *)window

// User has asked to see the dialog. Display it.
{
    if (!myCustomDial开发者_运维知识库og)
        [NSBundle loadNibNamed: @"MyCustomDialog" owner: self];



    [NSApp beginSheet: myCustomDialog
        modalForWindow: window
        modalDelegate: nil
        didEndSelector: nil
        contextInfo: nil];

    [NSApp runModalForWindow: myCustomDialog];

    // Dialog is up here.

    [NSApp endSheet: myCustomDialog];

    [myCustomDialog orderOut: self];
}

How is the myCustomDialog variable ever set to anything, and when?


It will be an outlet in your class, in the nib of the dialogue, file's owner is set to be whatever class you are calling this from, and the outlet is connected to it. When loading the nib with owner self, the outlet is populated.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜