How to pass data in conditional unwind segue?

前端 未结 3 409
失恋的感觉
失恋的感觉 2021-01-29 06:25

I try to build an rss reader. On the \"adding feed\" page, if I tap the \"add\" button, I hope to check if the feed is successfully added. If it is added, then trigger the unwin

3条回答
  •  鱼传尺愫
    2021-01-29 07:10

    - (UIViewController*)viewControllerForStoryboardName:(NSString*)storyboardName class:(id)class
    {
        UIStoryboard* storyboard = [UIStoryboard storyboardWithName:storyboardName bundle:nil];
        NSString* className = nil;
    
        if ([class isKindOfClass:[NSString class]])
            className = [NSString stringWithFormat:@"%@", class];
        else
            className = [NSString stringWithFormat:@"%s", class_getName([class class])];
    
        UIViewController* viewController = [storyboard instantiateViewControllerWithIdentifier:[NSString stringWithFormat:@"%@", className]];
        return viewController;
    }
    
    // get the view controller
        ViewController* viewController = (ViewController*)[self viewControllerForStoryboardName:@"MyStoryboard" class:[OtherViewController class]];
        // Pass data here
        viewController.data = myData;
    
    // or you can push it
        [self.navigationController pushViewController:viewController animated:YES];
    

提交回复
热议问题