Skip to content

Commit

Permalink
fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
xremix committed Oct 24, 2017
1 parent ec97fbd commit a23db81
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
2 changes: 1 addition & 1 deletion SwiftGS1Barcode/GS1Barcode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public class GS1Barcode: NSObject, Barcode {

private func parseApplicationIdentifier(_ ai: GS1ApplicationIdentifier, data: inout String)->Bool{
if(data.startsWith(ai.identifier)){
let pai = GS1BarcodeParser.parseGS1ApplicationIdentifier(ai, data: data)
_ = GS1BarcodeParser.parseGS1ApplicationIdentifier(ai, data: data)
// ai = GS1BarcodeParser.parseGS1ApplicationIdentifier(ai, data: data)
data = GS1BarcodeParser.reduce(data: data, by: ai)!

Expand Down
10 changes: 2 additions & 8 deletions SwiftGS1Barcode/StringExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ extension String{
let start = self.index(self.startIndex, offsetBy: from)
let end = self.index(start, offsetBy: length)
let range = start..<end

return self.substring(with: range) // play
return String(self[range])
}
func substring(_ from: Int, to: Int)->String{
return self.substring(from, length: to-from)
Expand All @@ -26,12 +25,7 @@ extension String{
func substring(to: Int)->String{
return self.substring(0, length: to)
}
func substring(to: String)->String{
if let index = self.index(of: to){
return self.substring(to:index)
}
return self
}

func index(of string: String, options: CompareOptions = .literal) -> Index? {
return range(of: string, options: options)?.lowerBound
}
Expand Down
6 changes: 1 addition & 5 deletions SwiftGS1BarcodeTests/StringTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@ class StringTests: XCTestCase {
XCTAssertEqual(testString.substring(from: testString.length), "")
XCTAssertEqual(testString, "Hello World") // Test Integration
}
func testSubstringToString() {
XCTAssertEqual(testString.substring(to: "World"), "Hello ")
XCTAssertEqual(testString.substring(to: "Hello World"), "")
XCTAssertEqual(testString, "Hello World") // Test Integration
}

func testStartsWith(){
XCTAssert(testString.startsWith("Hello"))
XCTAssert(!testString.startsWith("World"))
Expand Down

0 comments on commit a23db81

Please sign in to comment.