Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Shared Window Controllers
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Shared Window Controllers



Hi,

I'm having a bit of trouble understanding shared window controllers. I'm
using the Sketch project for reference. In the NSWindowController subclasses
of the shared controllers, there's a class method that reads like:


+ (id)sharedToolPaletteController {
    static SKTToolPaletteController *sharedToolPaletteController = nil;

    if (!sharedToolPaletteController) {
        sharedToolPaletteController = [[SKTToolPaletteController
allocWithZone:NULL] init];
    }

    return sharedToolPaletteController;
}


I don't understand how this will only cause one instance of the controller
to be instantiated and shared by anyone who calls it. Wouldn't
*sharedToolPaletteController get set to nil every time the function is
called? Or does the "static" label cause it to do something different?


Thanks,

King Chung Huang
Learning Commons
University of Calgary
_______________________________________________
studentdev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/studentdev
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.