Skip to content

Commit 4da7e79

Browse files
committed
Updated deprecated func
1 parent b2d2ad4 commit 4da7e79

2 files changed

Lines changed: 39 additions & 33 deletions

File tree

Samples/Basic/DocumentReaderObjectiveC-sample/DocumentReaderObjectiveC-sample/ViewController.m

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Samples/Basic/DocumentReaderSwift-sample/DocumentReaderSwift-sample/ViewController.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ class ViewController: UIViewController {
4444
self.initializationLabel.text = "Downloading database: \(progressValue)%"
4545
}, completion: { (success, error) in
4646
if success {
47-
DocReader.shared.initializeReader(license: licenseData) { (success, error) in
47+
let config = DocReader.Config(license: licenseData, licenseUpdateCheck: true, databasePath: nil)
48+
49+
DocReader.shared.initializeReader(config: config) { (success, error) in
4850
DispatchQueue.main.async {
4951
if success {
5052
self.activityIndicator.stopAnimating()

0 commit comments

Comments
 (0)