Как обновить значение продолжения в SecondViewController и Close, закрыть SecondViewController путем программирования - PullRequest
0 голосов
/ 25 августа 2018

Я создаю программу, которая при нажатии кнопки запускает процесс, затем всплывающее окно SecondView (в секундах просмотра есть поле метки, для которого необходимо продолжить загрузку / обновление значения процесса из Main ViewController).

Моя проблемаis:

MainViewController

        #import "ViewController.h"
        #import "SencondViewController.h"

        @implementation ViewController
        @synthesize passValue;

        - (void)viewDidLoad {
            [super viewDidLoad];

            // Do any additional setup after loading the view.
        }


        - (void)setRepresentedObject:(id)representedObject {
            [super setRepresentedObject:representedObject];

            // Update the view, if already loaded.
        }


        - (IBAction)btStart:(id)sender {

                @autoreleasepool{
                    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void) {
                        for (int i = 0; i < 100; i++) {
                            [NSThread sleepForTimeInterval:0.05];

                            dispatch_async(dispatch_get_main_queue(), ^(void) {
                                self->passValue = [@(i) stringValue];
                                [self performSegueWithIdentifier:@"LoadingView" sender:nil];

                            });

                        }
                    });
                }

        }

        - (IBAction)btClose:(id)sender {
        }


        - (void)prepareForSegue:(NSStoryboardSegue *)segue sender:(id)sender {
            if ([segue.identifier isEqualToString:@"LoadingView"]) {
                SencondViewController * secondVC = segue.destinationController;
                secondVC.progressValue = passValue;
            }

        }
        @end

В SeconViewController

    #import "SencondViewController.h"

    @interface SencondViewController ()

    @end

    @implementation SencondViewController

    - (void)viewDidLoad {
        [super viewDidLoad];
        // Do view setup here.
        @try{
            _textProcess.stringValue = _progressValue;}@catch(NSException *ex){};
    }

    @end
...