Adding category @interface to header file causes IB to freak out?

  • Not quite sure what's going on here, but I ran into a weird problem
    with one of my projects which I've replicated in a brand new "Cocoa
    Application" project for an example.

    1.  Create a new "Cocoa Application" project in Xcode.
    2.  Create a controller class in your new project called
    "TestController".
    3.  Add a single outlet to your TestController called "test."
    4.  Add an NSObject in IB for the MainMenu and set its class to the
    TestController.
    5.  Connect the test outlet from your TestController to the default
    window.
    6.  Drag and drop the "TestController.h" file from Xcode into the IB
    project window and note that nothing strange happens.
    7.  Now, add a category interface declaration to your header file like
    this:

    @interface TestController (TestCategory)
    - (void)blah;
    @end

    8.  Save and drag the TestController.h file into IB again, and this
    time note that IB complains "Outlet Unavailable.  The 'test' outlet of
    'Test Controller' is connected to 'Wnidow (Window)' but 'test' is no
    longer defined on TestController. This complaint is registered as a
    little warning symbol at the bottom right hand side of the IB project
    window; click on it to see the full warning.
    9. Look at your TestController definition again, see that the outlet
    *is* in fact defined, scratch your head, and send an email to the
    cocoa-dev mailing list.  ;-)

    Any thoughts?  I *should* be able to declare the @interface section of
    a category in the same .h file as the main @interface, shouldn't I?

    The final .h file looks like this:

    //  TestController.h

    #import <Cocoa/Cocoa.h>

    @interface TestController : NSObject {
    IBOutlet id test;
    }

    @end

    // Category on TestController.

    @interface TestController (TestCategory)
    - (void)blah;
    @end

    -Ryan

    Ryan Poling
  • On Dec 19, 2007, at 3:33 PM, Ryan Poling wrote:

    > --snip--
    > 8.  Save and drag the TestController.h file into IB again, and this
    > time note that IB complains "Outlet Unavailable.  The 'test' outlet
    > of 'Test Controller' is connected to 'Wnidow (Window)' but 'test' is
    > no longer defined on TestController. This complaint is registered as
    > a little warning symbol at the bottom right hand side of the IB
    > project window; click on it to see the full warning.
    > 9. Look at your TestController definition again, see that the outlet
    > *is* in fact defined, scratch your head, and send an email to the
    > cocoa-dev mailing list.  ;-)
    >
    > Any thoughts?  I *should* be able to declare the @interface section
    > of a category in the same .h file as the main @interface, shouldn't I?

    My first thought is you shouldn't be dropping the header into IB (if
    you re using IB3).
previous month december 2007 next month
MTWTFSS
          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