Vinamrata Singal
Vinamrata Singal

Reputation: 1

PrepareForSegue Not Passing All of the Data?

I am using a modal segue to pass data from SignUpViewController to RAVerificationViewController. For some reason, my name, password, phone, and email values are nil but dorm and role choices show up (they are values selected from a picker). I see that they're being passed correctly from the first view controller but they don't show up in the next one. Help!

- (void)prepareForSegue:(UIStoryboardPopoverSegue *)segue sender:(id)sender {
    NSLog(@"prepareForSegue: %@", segue.identifier);
    if ([segue.identifier isEqualToString:@"signUpToRAVerification"]) {
        RAVerificationViewController *ravc = (RAVerificationViewController *)segue.destinationViewController;
        NSInteger roleRow = [_rolePickerChoice selectedRowInComponent:0];
        NSString *role = [self pickerView: _rolePickerChoice titleForRow:roleRow forComponent:1];
        ravc.role = role;
        NSString *email = _emailOneField.text;
        ravc.name = _nameField.text;
        ravc.password = _passwordTwoField.text;
        ravc.email = email;
        ravc.phoneNumber = _phoneNumberField.text;
        NSInteger dormRow = [_dormPickerChoice selectedRowInComponent:0];
        NSString *dorm = [self pickerView: _dormPickerChoice titleForRow:dormRow forComponent:1];
        ravc.dormChoice= dorm;
    }
}

What I'm doing with the data in the other VC:

if([_raCodeField.text isEqualToString:code]) {
        NSLog(@"The email is: %@", email);
        //RA good to go, let's save him/her in our DB!
        PFUser* user = [PFUser user];
        user[@"role"] = _role;
        user[@"Name"] = name;
        user.password = password;
        user.email = email;
        user.username = email;
        user[@"phone_number"] = phoneNumber;
        user[@"dorm"] = _dormChoice;
        [user signUpInBackgroundWithBlock:^(BOOL succeeded, NSError *error)

For the entire SignUpViewController: https://gist.github.com/vinamratasingal/542dc10bf1674173d2de

For the entire raVerificationViewController: https://gist.github.com/vinamratasingal/758d3a11a3ddf6d7e3a3

Upvotes: 0

Views: 72

Answers (1)

user3344977
user3344977

Reputation: 3604

You're not showing us your header file for your RAVerificationViewController, but I can almost guarantee that the problem is that your properties are using the weak property attribute. You need to make sure they are using the strong property attribute.

Otherwise, the data will not have any strong references and it will be deallocated from memory.

Upvotes: 1

Related Questions