Dev Center
Swift
Objective-C
Table of contents

Parameter and Runtime Settings Advanced Methods

Method Description
initRuntimeSettingsWithFile Initialize runtime settings with the settings in a given JSON file.
initRuntimeSettingsWithString Initialize runtime settings with the settings in a given JSON string.
appendTplFileToRuntimeSettings Append a new template file to the current runtime settings.
appendTplStringToRuntimeSettings Append a new template string to the current runtime settings.
allParameterTemplateNames Gets the parameter templates name array.
outputSettingsToFile Output runtime settings to a settings file (JSON file).
outputSettingsToString Output runtime settings to a string.
setModeArgument Sets the optional argument for a specified mode in Modes parameters.
getModeArgument Gets the optional argument for a specified mode in Modes parameters.

initRuntimeSettingsWithFile

Initialize runtime settings with the parameters obtained from a JSON file.

  • Objective-C
  • Swift
  1. - (BOOL)initRuntimeSettingsWithFile:(NSString* _Nonnull)fileName
                       conflictMode:(EnumConflictMode)conflictMode
                              error:(NSError* _Nullable * _Nullable)error;
    
  2. func initRuntimeSettingsWithFile(_ fileName: String, conflictMode: EnumConflictMode) throws
    

Parameters

[in] fileName: The settings file path.
[in] conflictMode: The parameter setting mode, which decides whether to inherit parameters from previous template settings or to overwrite previous settings with the new template.
[in,out] error: A pointer to an error object.

An error occurs when:

  • The file is not found.
  • There exists parameters that are invalid or out of range.
  • The template name is invalid.

Code Snippet

  • Objective-C
  • Swift
  1. [barcodeReader initRuntimeSettingsWithFile:@"your template file path" conflictMode:EnumConflictModeOverwrite error:nil];
    
  2. do{
       try barcodeReader.initRuntimeSettingsWithFile("your template file path", conflictMode:EnumConflictMode.overwrite)
    }catch{
       // Add your code to deal with exceptions
    }
    

initRuntimeSettingsWithString

Initialize runtime settings with the parameters obtained from a JSON string.

  • Objective-C
  • Swift
  1. - (BOOL)initRuntimeSettingsWithString:(NSString* _Nonnull)content
                         conflictMode:(EnumConflictMode)conflictMode
                                error:(NSError* _Nullable * _Nullable)error;
    
  2. func initRuntimeSettingsWithString(_ content: String, conflictMode: EnumConflictMode) throws
    

Parameters

[in] content: A JSON string that represents the content of the settings.
[in] conflictMode: The parameter setting mode, which decides whether to inherit parameters from previous template setting or to overwrite previous settings with the new template.
[in,out] error: A pointer to an error object.

An error occurs when:

  • The library failed to parse the JSON string.
  • There exists parameters that are invalid or out of range.
  • The template name is invalid.

Code Snippet

  • Objective-C
  • Swift
  1. [barcodeReader initRuntimeSettingsWithString:@"{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\", \"BarcodeFormatIds\":[\"BF_QR_CODE\"], \"ExpectedBarcodesCount\":10}}" conflictMode:EnumConflictModeOverwrite error:nil];
    
  2. do{
       try barcodeReader.initRuntimeSettingsWithString("{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\", \"BarcodeFormatIds\":[\"BF_QR_CODE\"], \"ExpectedBarcodesCount\":10}}", conflictMode:EnumConflictMode.overwrite)
    }catch{
       // Add your code to deal with exceptions
    }
    

appendTplFileToRuntimeSettings

Append a new template file to the current runtime settings.

  • Objective-C
  • Swift
  1. - (BOOL)appendTplFileToRuntimeSettings:(NSString * _Nonnull)fileName
                          conflictMode:(EnumConflictMode)conflictMode
                                 error:(NSError * _Nullable *_Nullable)error;
    
  2. func appendTplFileToRuntimeSettings(_ fileName: String, conflictMode: EnumConflictMode) throws
    

Parameters

[in] fileName: The settings file path.
[in] conflictMode: The parameter setting mode, which decides whether to inherit parameters from previous template settings or to overwrite previous settings with the new template.
[in,out] error: A pointer to an error object.

An error occurs when:

  • The file is not found.
  • There exists parameters that are invalid or out of range.
  • The template name is invalid.

Code Snippet

  • Objective-C
  • Swift
  1. [barcodeReader appendTplFileToRuntimeSettings:@"your template file path" conflictMode:EnumConflictModeIgnore error:nil];
    
  2. do{
       try barcodeReader.appendTplFileToRuntimeSettings("your template file path", conflictMode:EnumConflictMode.ignore, error:&error)
    }catch{
       // Add your code to deal with exceptions
    }
    

appendTplStringToRuntimeSettings

Append a new template string to the current runtime settings.

  • Objective-C
  • Swift
  1. - (BOOL)appendTplStringToRuntimeSettings:(NSString * _Nonnull)content
                            conflictMode:(EnumConflictMode)conflictMode
                                   error:(NSError *_Nullable *_Nullable)error;
    
  2. func appendTplStringToRuntimeSettings(_ content: String, conflictMode: EnumConflictMode) throws
    

Parameters

[in] content: A JSON string that represents the content of the settings.
[in] conflictMode: The parameter setting mode, which decides whether to inherit parameters from previous template setting or to overwrite previous settings with the new template.
[in,out] error: A pointer to an error object.

An error occurs when:

  • The library failed to parse the JSON string.
  • There exists parameters that are invalid or out of range.
  • The template name is invalid.

Code Snippet

  • Objective-C
  • Swift
  1. [barcodeReader initRuntimeSettingsWithString:@"{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\", \"BarcodeFormatIds\":[\"BF_QR_CODE\"], \"ExpectedBarcodesCount\":10}}" conflictMode:EnumConflictModeOverwrite error:nil];
    [barcodeReader appendTplStringToRuntimeSettings:@"{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\", \"BarcodeFormatIds\":[\"BF_OneD\"], \"ExpectedBarcodesCount\":20}}" conflictMode:EnumConflictModeIgnore error:nil];
    
  2. do{
       try barcodeReader.initRuntimeSettingsWithString("{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\", \"BarcodeFormatIds\":[\"BF_QR_CODE\"], \"ExpectedBarcodesCount\":10}}", conflictMode:EnumConflictMode.Overwrite)
       try barcodeReader.appendTplStringToRuntimeSettings("{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\", \"BarcodeFormatIds\":[\"BF_OneD\"], \"ExpectedBarcodesCount\":20}}", conflictMode:EnumConflictMode.ignore)
    }catch{
       // Add your code to deal with exceptions
    }
    

allParameterTemplateNames

Get count of parameter templates.

  • Objective-C
  • Swift
  1. - (NSArray<NSString*>* _Nullable)allParameterTemplateNames: (NSError *__autoreleasing  _Nullable * _Nullable)error;
    
  2. func allParameterTemplateNames() throws -> [String]
    

Parameters

[in,out] error: A pointer to an error object.

An error occurs when:

  • The library failed to get all template names.

Return Value

The template name array.

Code Snippet

  • Objective-C
  • Swift
  1. NSArray* allTplNames = [barcodeReader allParameterTemplateNames:nil];
    
  2. let allTplNames = do{
       try barcodeReader.allParameterTemplateNames()
    }catch{
       // Add your code to deal with exceptions
    }
    

outputSettingsToFile

Outputs runtime settings and save them into a settings file (JSON file).

  • Objective-C
  • Swift
  1. - (BOOL)outputSettingsToFile:(NSString *_Nullable)filePath 
                settingsName:(NSString*_Nonnull)settingsName 
                       error:(NSError*_Nullable *_Nullable)error;
    
  2. func outputSettingsToFile(_ filePath: String?, settingsName: String) throws
    

Parameters

[in] filePath The path of the output file which stores current settings.
[in] settingsName A unique name for declaring current runtime settings.
[in,out] error: A pointer to an error object.

An error occurs when:

  • The file path is not found.
  • The library failed to output the settings.

Code Snippet

  • Objective-C
  • Swift
  1. settingsName = [barcodeReader outputSettingsToFile:@"your saving file path" settingsName:@"currentRuntimeSettings" error:nil];
    
  2. do{
       let settingsName = try barcodeReader.outputSettingsToFile("your saving file path", settingsName:"currentRuntimeSettings")
    }catch{
       // Add your code to deal with exceptions
    }
    

outputSettingsToString

Output runtime settings to a string.

  • Objective-C
  • Swift
  1. - (NSString *_Nullable)outputSettingsToString:(NSString*_Nonnull)settingsName 
                                        error:(NSError* _Nullable * _Nullable)error;
    
  2. func outputSettingsToString(_ settingsName: String) throws -> String
    

Parameters

[in] settingsName A unique name for declaring current runtime settings.
[in,out] error: A pointer to an error object.

An error occurs when:

  • The library failed to output the settings.

Return Value

The output string which stores the content of current settings.

Code Snippet

  • Objective-C
  • Swift
  1. settingsName = [barcodeReader outputSettingsToString:@"currentRuntimeSettings" error:nil];
    
  2. do{
       let settingsName = try barcodeReader.outputSettingsToString("currentRuntimeSettings")
    }catch{
       // Add your code to deal with exceptions
    }
    

setModeArgument

Sets the optional argument for a specified mode in Modes parameters.

  • Objective-C
  • Swift
  1. - (BOOL)setModeArgument:(NSString* _Nonnull)modeName
                    index:(NSInteger)index 
                    argumentName:(NSString* _Nonnull)argumentName
                    argumentValue:(NSString* _Nonnull)argumentValue
                    error:(NSError* _Nullable * _Nullable)error;
    
  2. func setModeArgument(_ modeName: String, index: Int, argumentName: String, argumentValue: String) throws
    

Parameters

[in] modesName The mode parameter name to set argument.
[in] index The array index of mode parameter to indicate a specific mode.
[in] argumentName The name of the argument to set.
[in] argumentValue The value of the argument to set.
[in,out] error: A pointer to an error object.

An error occurs when:

  • The library failed to set the mode argument. It might because you input incorrect modeName, index, argumentName or argumentValue.

Code Snippet

  • Objective-C
  • Swift
  1. iPublicRuntimeSettings *settings = [barcodeReader getRuntimeSettings:nil];
    settings.binarizationModes = @[@(EnumBinarizationModeLocalBlock)];
    [barcodeReader updateRuntimeSettings:settings error:nil];
    [barcodeReader setModeArgument:@"BinarizationModes" index:0 argumentName:@"EnableFillBinaryVacancy" argumentValue:"1" error:nil];
    
  2. do{
       let settings = try barcodeReader.getRuntimeSettings()
       settings.binarizationModes = [EnumBinarizationMode.localBlock]
       try barcodeReader.updateRuntimeSettings(settings)
       try barcodeReader.setModeArgument("BinarizationModes", index: 0, argumentName: "EnableFillBinaryVacancy", argumentValue: "1")
    }catch{
       // Add your code to deal with exceptions
    }
    

Remarks

Check follow link for available modes and arguments:

getModeArgument

Gets the optional argument for a specified mode in Modes parameters.

  • Objective-C
  • Swift
  1. -(NSString* _Nonnull)getModeArgument:(NSString* _Nonnull)modeName
                               index:(NSInteger)index
                        argumentName:(NSString* _Nonnull)argumentName
                               error:(NSError* _Nullable * _Nullable)error;
    
  2. func getModeArgument(_ modeName: String, index: Int, argumentName: String) throws -> String
    

Parameters

[in] modesName The mode parameter name to get arguments.
[in] index The array index of mode parameter to indicate a specific mode.
[in] argumentName The name of the argument to get.
[in,out] error: A pointer to an error object.

An error occurs when:

  • The library failed to get the mode argument. It might because you input incorrect modeName, index or argumentName.

Return Value

the optional argument for a specified mode

Code Snippet

  • Objective-C
  • Swift
  1. iPublicRuntimeSettings *settings = [barcodeReader getRuntimeSettings:nil];
    settings.binarizationModes = @[@(EnumBinarizationModeLocalBlock)];
    [barcodeReader updateRuntimeSettings:settings error:nil];
    [barcodeReader setModeArgument:@"BinarizationModes" index:0 argumentName:@"EnableFillBinaryVacancy" argumentValue:"1" error:nil];
    argumentValue = [barcodeReader getModeArgument:@"BinarizationModes" index:0 argumentName:@"EnableFillBinaryVacancy" error:&error];
    
  2. let settings = do{
       try barcodeReader.getRuntimeSettings()
       settings.binarizationModes = [EnumBinarizationMode.localBlock]
       try barcodeReader.updateRuntimeSettings(settings)
       try barcodeReader.setModeArgument("BinarizationModes", index: 0, argumentName: "EnableFillBinaryVacancy", argumentValue: "1")
       let argumentValue = try barcodeReader.getModeArgument("BinarizationModes", index: 0, argumentName: "EnableFillBinaryVacancy")
    }catch{
       // Add your code to deal with exceptions
    }
    

Remarks

Check follow link for available modes and arguments:

This page is compatible for:

Version 7.5.0

Is this page helpful?

YesYes NoNo

In this article:

latest version

  • Latest version
  • Version 10.x
    • Version 10.2.10
    • Version 10.0.21
    • Version 10.0.20
    • Version 10.2.10
    • Version 10.0.21
    • Version 10.0.20
  • Version 9.x
    • Version 9.6.40
    • Version 9.6.20
    • Version 9.6.11
    • Version 9.6.10
    • Version 9.6.0
    • Version 9.4.0
    • Version 9.2.11
    • Version 9.2.10
    • Version 9.0.2
    • Version 9.0.1
    • Version 9.0.0
    • Version 9.6.40
    • Version 9.6.20
    • Version 9.6.10
    • Version 9.6.0
    • Version 9.4.0
    • Version 9.2.13
    • Version 9.2.10
    • Version 9.0.2
    • Version 9.0.1
    • Version 9.0.0
  • Version 8.x
    • Version 8.9.3
    • Version 8.9.1
    • Version 8.9.0
    • Version 8.8.0
    • Version 8.6.0
    • Version 8.4.0
    • Version 8.2.1
    • Version 8.2.0
    • Version 8.1.2
    • Version 8.1.0
    • Version 8.0.0
    • Version 8.9.3
    • Version 8.9.1
    • Version 8.9.0
    • Version 8.8.0
    • Version 8.6.0
    • Version 8.4.0
    • Version 8.2.1
    • Version 8.2.0
    • Version 8.1.2
    • Version 8.1.0
    • Version 8.0.0
  • Version 7.x
    • Version 7.6.0
    • Version 7.5.0
    • Version 7.6.0
    • Version 7.5.0
Change +