@@ -47,39 +47,43 @@ - (void)initializationReader {
4747 [RGLDocReader.shared prepareDatabase: @" Full" progressHandler: ^(NSProgress * _Nonnull progress) {
4848 self.initializationLabel .text = [NSString stringWithFormat: @" %.1f " , progress.fractionCompleted * 100 ];
4949 } completion: ^(BOOL successful, NSError * _Nullable error) {
50- if (successful) {
51- self.initializationLabel .text = @" Initialization..." ;
52- [RGLDocReader.shared initializeReader: licenseData completion: ^(BOOL successful, NSError * _Nullable error ) {
53- if (successful) {
54- [self .activityIndicator stopAnimating ];
55- [self .initializationLabel setHidden: YES ];
56- [self .userRecognizeImage setHidden: NO ];
57- [self .useCameraViewControllerButton setHidden: NO ];
58- [self .customCamera setHidden: NO ];
59- [self .pickerView setHidden: NO ];
60- [self .pickerView reloadAllComponents ];
61- [self .pickerView selectRow: 0 inComponent: 0 animated: NO ];
62-
63- RGLScenario *scenario = [RGLDocReader shared ].availableScenarios .firstObject ;
64- if (scenario) {
65- [RGLDocReader shared ].processParams .scenario = scenario.identifier ;
50+ dispatch_async (dispatch_get_main_queue (), ^{
51+ if (successful) {
52+ self.initializationLabel .text = @" Initialization..." ;
53+ RGLConfig *config = [RGLConfig configWithLicenseData: licenseData licenseUpdateCheck: YES databasePath: nil ];
54+
55+ [RGLDocReader.shared initializeReaderWithConfig: config completion: ^(BOOL successful, NSError * _Nullable error ) {
56+ if (successful) {
57+ [self .activityIndicator stopAnimating ];
58+ [self .initializationLabel setHidden: YES ];
59+ [self .userRecognizeImage setHidden: NO ];
60+ [self .useCameraViewControllerButton setHidden: NO ];
61+ [self .customCamera setHidden: NO ];
62+ [self .pickerView setHidden: NO ];
63+ [self .pickerView reloadAllComponents ];
64+ [self .pickerView selectRow: 0 inComponent: 0 animated: NO ];
65+
66+ RGLScenario *scenario = [RGLDocReader shared ].availableScenarios .firstObject ;
67+ if (scenario) {
68+ [RGLDocReader shared ].processParams .scenario = scenario.identifier ;
69+ }
70+ [RGLDocReader shared ].functionality .singleResult = YES ;
71+
72+ for (RGLScenario *scenario in RGLDocReader.shared .availableScenarios ) {
73+ NSLog (@" %@ " , scenario);
74+ NSLog (@" ---------" );
75+ }
76+ } else {
77+ [self .activityIndicator stopAnimating ];
78+ self.initializationLabel .text = [NSString stringWithFormat: @" Initialization error: %@ " , error];
79+ NSLog (@" %@ " , error);
6680 }
67- [RGLDocReader shared ].functionality .singleResult = YES ;
68-
69- for (RGLScenario *scenario in RGLDocReader.shared .availableScenarios ) {
70- NSLog (@" %@ " , scenario);
71- NSLog (@" ---------" );
72- }
73- } else {
74- [self .activityIndicator stopAnimating ];
75- self.initializationLabel .text = [NSString stringWithFormat: @" Initialization error: %@ " , error];
76- NSLog (@" %@ " , error);
77- }
78- }];
79- } else {
80- self.initializationLabel .text = [NSString stringWithFormat: @" Downloading database error: %@ " , error];
81- NSLog (@" %@ " , error);
82- }
81+ }];
82+ } else {
83+ self.initializationLabel .text = [NSString stringWithFormat: @" Downloading database error: %@ " , error];
84+ NSLog (@" %@ " , error);
85+ }
86+ });
8387 }];
8488}
8589
0 commit comments