poseAsClass and class methods

  • I'm substituting my own class for an existing one using
    NSObject:poseAsClass, and everything has been working fine, but I now
    want to override a class method rather than just a couple of instance
    methods.  How do I call through to the original class' class method?
    Here's a snippet from the relevant code:


    @interface ComStClairSoftSavePanel : NSSavePanel {

    + (NSSavePanel *)savePanel;
    - (void)becomeKeyWindow;

    [more method declarations....]



    @implementation ComStClairSoftDFSavePanel

    + (NSSavePanel *)savePanel
    NSLog(@"ComStClairSoftSavePanel:savePanel called");

    return [super savePanel];

    [more method implementations....]


    After posing ComStClairSoftSavePanel for NSSavePanel, all of the
    instance methods, such as my replacement for becomeKeyWindow, have
    been working fine.  But after adding the above code and calling
    [NSSavePanel savePanel] from my test app, I get the console messages:

    ComStClairSoftSavePanel:savePanel called
    +[NSSavePanel savePanel]: selector not recognized
    +[NSSavePanel savePanel]: selector not recognized

    Why?  My posed +savePanel method is getting called, Obj-C seems to
    recognize that my [super savePanel] call should go to the NSSavePanel
    class, and that it's a class method rather than an instance method,
    so why can't it dispatch it?  Is it impossible to call through to
    overridden class methods when posing for another class?


      - Jon
            Jon Gotow                    <gotow...>
        St. Clair Software              http://www.stclairsoft.com/
        Fax (540)552-5898              ftp://ftp.stclairsoft.com/
previous month july 2002 next month
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
Go to today