尝试将数据从当前 VC 传递到下一个,但首先检查用户输入的信息是否正确

Trying to pass Data from current VC to the next but first checking if the user inputs the correct info

我正在尝试使用 IBAction 将数据从当前视图控制器传递到下一个视图控制器,因为我还需要在转到第二个视图控制器之前检查用户是否使用了正确的用户电子邮件和 ID。我还是 Objective-C 和 Xcode 的新手。我认为这会奏效,但事实并非如此。它不会将数字 15 传递给第二个 VC。我希望它是这样的。请帮我想办法做到这一点。这实际上是我今天到期的期末项目。哈哈

- (IBAction)signInButtonPressed:(id)sender {

    DatabaseManager *data = [DatabaseManager new]; // A DB Using SQLite3

    if (![self.studentEmailField.text isEqualToString:@""] && ![self.studentMDCID.text isEqualToString:@""]) {

        if ([data checkStudentEmail:self.studentEmailField.text checkStudentID:self.studentMDCID.text]) {

            StudentMainPageViewController *secoundVC = [StudentMainPageViewController new];

            secoundVC.rowInDB = 15;

            UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];

            UIViewController *StudentMainPageVC = [mainStoryboard instantiateViewControllerWithIdentifier:@"StudentMainPageID"];

            [self presentViewController:StudentMainPageVC animated:TRUE completion:nil];
        }
    }
}

尝试使用以下解决方案:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 
{
    if ([segue.identifier isEqualToString:@"YourSegueIdentifier"]) 
    {
        DestinationViewController *dest = [segue destinationViewController];

        dest.myData = self.myData; 
    }
}