Adding category @interface to header file causes IB to freak out?
Adding category @interface to header file causes IB to freak out?
- Subject: Adding category @interface to header file causes IB to freak out?
- From: Ryan Poling <email@hidden>
- Date: Wed, 19 Dec 2007 15:33:07 -0800
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
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden