Reputation: 2801
Hey guys I am unable to find or connect my UITextField loginId
with my custom viewcontroller.h
file. when I try to get that class using NSString *data = loginId.text;
it tells me that it is non existant.
.h
file:
#import <UIKit/UIKit.h>
UITextField *loginId;
UITextField *password;
@interface loginController : UIViewController
- (IBAction) loginBegin:(id) sender;
@end
.m
file:
NSString *intakePass = loginId.text;
I tried cleaning my project but that seems not to work. I notice that when I go to the storyboard to add in a custom class usually the classname I make in the .h
file will drop down but nothing comes up. But it is set to loginId
.
Suggestions, thoughts?
Upvotes: 0
Views: 51
Reputation: 25692
IBOutlet is the Key to Make them visible in XIB. So u must specify them as IBOutlet.
You must drag UITextField from library, not other components.Please verify it on XIB that you are connecting Text Field and make sure the class name of text field. it should be UITextField or UITextField Subclass.
@interface loginController : UIViewController{
IBOutlet UITextField *loginId;
IBOutlet UITextField *password;
}
@property(weak,nonatomic) IBOutlet UITextField *loginId;
@property(weak,nonatomic) IBOutlet UITextField *password;
- (IBAction) loginBegin:(id) sender;
@end
Upvotes: 3
Reputation: 625
IBOutlet your UITextField as below in your .m file:
@interface ViewController ()
@property(weak,nonatomic) IBOutlet UITextField *loginId;
@property(weak,nonatomic) IBOutlet UITextField *password;
@end
now you can connect your textfile in xib
Upvotes: 0