ios

写法1:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
    if ([segue.identifier isEqualToString:@"ProjectDetailsSegue"]) {
        ProjectDetailsViewController *detailsVC = segue.destinationViewController;
        detailsVC.idString = sender;
    }

写法2:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
    if ([[segue destinationViewController] isKindOfClass:[EZWifiConfigViewController class]]) {
        ((EZWifiConfigViewController *)[segue destinationViewController]).ssid = self.nameTextField.text;
        ((EZWifiConfigViewController *)[segue destinationViewController]).password = self.passwordTextField.text;
    }
}
原文地址:https://www.cnblogs.com/codemakerhj/p/5751744.html