PrepareForSegue没有传递所有数据?

时间:2014-09-04 21:51:39

标签: ios objective-c segue

我使用模态segue将数据从SignUpViewController传递到RAVerificationViewController。出于某种原因,我的姓名,密码,电话和电子邮件值都是零,但宿舍和角色选择显示(它们是从选择器中选择的值)。我看到它们正在从第一个视图控制器正确传递,但它们不会出现在下一个视图控制器中。救命!

- (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;
    }
}

我正在对其他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)

对于整个SignUpViewController:https://gist.github.com/vinamratasingal/542dc10bf1674173d2de

对于整个raVerificationViewController:https://gist.github.com/vinamratasingal/758d3a11a3ddf6d7e3a3

1 个答案:

答案 0 :(得分:1)

您没有向我们展示RAVerificationViewController的头文件,但我几乎可以保证问题在于您的属性正在使用weak属性属性。您需要确保他们使用strong属性属性。

否则,数据将没有任何强引用,它将从内存中释放。