Skip to content

Commit

Permalink
Merge pull request #5 from xremix/hotfix-simultaneously-access
Browse files Browse the repository at this point in the history
Hotfix simultaneously access - Xcode 9
  • Loading branch information
xremix authored Oct 24, 2017
2 parents cfc2934 + a9932ba commit a82d254
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion SwiftGS1Barcode.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'SwiftGS1Barcode'
s.version = '0.3.7'
s.version = '0.3.8'
s.summary = 'A GS1 Barcode Library and Parser for Swift'

s.description = <<-DESC
Expand Down
17 changes: 10 additions & 7 deletions SwiftGS1Barcode/GS1Barcode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,14 @@ public class GS1Barcode: NSObject, Barcode {
return lastParseSuccessfull && raw != "" && raw != nil
}

private func parseApplicationIdentifier(_ ai: inout GS1ApplicationIdentifier, data: inout String)->Bool{
private func parseApplicationIdentifier(_ ai: GS1ApplicationIdentifier, data: inout String)->Bool{
if(data.startsWith(ai.identifier)){
ai = GS1BarcodeParser.parseGS1ApplicationIdentifier(ai, data: data)
let pai = GS1BarcodeParser.parseGS1ApplicationIdentifier(ai, data: data)
// ai = GS1BarcodeParser.parseGS1ApplicationIdentifier(ai, data: data)
// Fixes issue where two AIs have the same identifier (TODO: should maybe get rid of gtinIndicatorDigit)
if ai.identifier == "01"{
applicationIdentifiers["gtinIndicatorDigit"] = GS1BarcodeParser.parseGS1ApplicationIdentifier(applicationIdentifiers["gtinIndicatorDigit"]!, data: data)
if pai.identifier == "01"{
let digit = GS1BarcodeParser.parseGS1ApplicationIdentifier(self.applicationIdentifiers["gtinIndicatorDigit"]!, data: data)
applicationIdentifiers["gtinIndicatorDigit"] = digit
}
data = GS1BarcodeParser.reduce(data: data, by: ai)!

Expand All @@ -110,11 +112,11 @@ public class GS1Barcode: NSObject, Barcode {

// Checking the AIs by it's identifier and passing it to the Barcode Parser to get the value and cut the data
var foundOne = false
for aiKey in applicationIdentifiers.keys{
for (key, applicationIdentifier) in applicationIdentifiers {
// Exclude the gtinIndicatorDigit, because it get's added later for the gtin identifier
if aiKey != "gtinIndicatorDigit"{
if key != "gtinIndicatorDigit"{
// If could parse ai, continue and do the loop once again
if(parseApplicationIdentifier(&applicationIdentifiers[aiKey]!, data: &data!)){
if(parseApplicationIdentifier(applicationIdentifier, data: &data!)){
foundOne = true
continue
}
Expand All @@ -131,3 +133,4 @@ public class GS1Barcode: NSObject, Barcode {
return true
}
}

2 changes: 1 addition & 1 deletion SwiftGS1Barcode/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.3.7</string>
<string>0.3.8</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down

0 comments on commit a82d254

Please sign in to comment.