I'm new to developing in iOS and successfully 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 a new class
SimpleViewController : NSObject
#import <Cocoa/Cocoa.h>
@interface SimpleViewController : NSObject {
IBOutlet NSTextField *aField;
IBOutlet NSButton *aButton;
}
@end
In Interface Builder:
SimpleViewController
from my library
into the main.nib SimpleViewController
to view
elements to connect my outletsEverything above works great. Now for the same thing in an iPhone app:
Project B:
In XCode:
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:
SimpleViewController
from my library
into the main.nib 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
In iOS development, we use UIButton
and UITextField
and etc, (see the iphone developer documentation).
And no, you don't need to forward declare those classes (it made you since they weren't included in UIKit