I'm trying to send text generated by the user from the AuthenticationViewController to MainProfileViewController. I'm not receiving an error report. The label just doesn't even appear in the MainProfileViewController. The outlets are correctly hooked up. Thanks for the help!
#import <UIKit/UIKit.h>
@class MainProfileViewController;
@interface AuthenticationViewController : UIViewController
{
MainProfileViewController *mainProfileViewController;
}
@property (retain, nonatomic) IBOutlet UITextField *usernameTextField;
@end
#import "AuthenticationViewController.h"
#import "MainProfileViewController.h"
@interface AuthenticationViewController ()
@end
@implementation AuthenticationViewController
@synthesize usernameTextField;
- (IBAction)createAccount: (id)sender {
{
mainProfileViewController = [[MainProfileViewController alloc] init];
mainProfileViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
mainProfileViewController.userText.text = usernameTextField.text;
[self presentViewController:mainProfileViewController animated:YES completion:nil];
}
}
@end
#import <UIKit/UIKit.h>
#import "AuthenticationViewController.h"
@interface MainProfileViewController : UIViewController
{
UITextField *userText;
}
@property (retain, nonatomic) IBOutlet UILabel *resultLabel;
@property (retain, nonatomic) IBOutlet UITextField *userText;
@property (retain, nonatomic) NSString *textPass;
@end
#import "MainProfileViewController.h"
#import "AuthenticationViewController.h"
@interface MainProfileViewController ()
@end
@implementation MainProfileViewController
@synthesize resultLabel, userText, textPass;
- (void)viewDidLoad
{
userText.text = textPass;
[super viewDidLoad];
}
@end
OK, there's a few things you're doing wrong. First off, you're instantiating a local
MainProfileViewController
instead of instantiating the one that you have an ivar pointing to.The second thing that you're doing wrong is trying to send over the view from the
AuthenticationViewController
to theMainProfileViewController
. You shouldn't do that. Instead, pass the text itself; otherwise you are just overwriting pointers, and nothing will show up.edit: I suppose it's not required that you have an ivar to the new view controller you want to present... But the point is that you cannot instantiate one, and then set the parameter on the one you did not instantiate (it will be nil).