0

連絡先(loggedinUser)の情報をdestinationViewControllersの連絡先(currentUser)に渡そうとしてセグエを作成しているのですが、なぜか通じません。以下のコードに何か問題がありますか?

元のビュー:

...
self.loggedInUser.firstName = @"first name";
self.loggedInUser.lastName = @"last name";
self.loggedInUser.company = @"company"
self.loggedInUser.position = @"position";
[self performSegueWithIdentifier:@"profileSegue" sender:self];
...

-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
ProfileViewController *pvc = (ProfileViewController *) [segue destinationViewController];
pvc.currentUser = self.loggedInUser; }

次に、DestinationViewController のラベルに値を表示しています。

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    NSString *fullName = [NSString stringWithFormat:@"%@ %@", currentUser.firstName, currentUser.lastName];
    fullNameLabel.text = fullName;
    companyLabel.text = currentUser.company;
    positionLabel.text = currentUser.position;
}

LoggedInUser と currentUser はどちらも「Contact」タイプです。しかし、ラベルは null を表示するだけです。明らかな何かが欠けていますか?

編集

これは、self.loggedinUser が prepareForSegue に渡されないという問題です。

ヘッダー コード:

#import "Contact.h"

@interface LoginViewController : UIViewController
{
}

...

@property (nonatomic, retain) Contact *loggedInUser;
4

1 に答える 1