I'm new to developing in iOS and succesfully ran through a tutorial on how to create and connect outlets in a Mac OSX Cocoa App. However, when I try to follow the same process for my iPhone app, I keep hitting walls... (Apologies for the lengthy example- please bear with)
Project A:
In XCode:
- Create new Mac OSX Cocoa Application
- Create a new class SimpleViewController : NSObject
#import <Cocoa/Cocoa.h>
@interface SimpleViewController : NSObject {
IBOutlet NSTextField *aField;
IBOutlet NSButton *aButton;
}
@end
In Interface Builder:
- File > Read class files
- Drag SimpleViewController from my library into the main.nib
- Ctl-drag from SimpleViewController to view elements to connect my outlets
Everything above works great. Now for the same thing in an iPhone app:
Project B:
In XCode:
- Create new iPhone OS Window-Based Application
- Create a new class SimpleViewController : UIViewController
#import <UIKit/UIKit.h>
@class NSTextField;
@class NSButton;
@interface EmbedComplexViewController : UIViewController {
IBOutlet NSTextField *aField;
IBOutlet NSButton *aButton;
}
@end
(Notice my view controller is now an extension of UIViewController, not NSObject. Also, this time I need to use forward class declarations for my outlet classes. Not a problem, but is this necessary?)
In Interface Builder:
- File > Read class files
- Drag SimpleViewController from my library into the main.nib
- Ctl-drag from SimpleViewController to view elements - BUT now I can't see any of my declared outlet member variables. Instead, the only outlet option I have is 'view'
What more do I need to do to have my declared outlets show up?
Thanks- Yarin