ApolloZhu / swift_qrcodejs

@@ -45,10 +45,11 @@
Loading
45 45
                 encoding: String.Encoding = .utf8,
46 46
                 errorCorrectLevel: QRErrorCorrectLevel = .H,
47 47
                 withBorder hasBorder: Bool = true) {
48 -
        guard let typeNumber = try? QRCodeType.typeNumber(of: text, errorCorrectLevel: errorCorrectLevel, encoding: encoding)
49 -
            , let model = QRCodeModel(text: text, encoding: encoding, typeNumber: typeNumber, errorCorrectLevel: errorCorrectLevel)
48 +
        
49 +
        guard let model = QRCodeModel(text: text, encoding: encoding, errorCorrectLevel: errorCorrectLevel)
50 50
            else { return nil }
51 -
        self.typeNumber = typeNumber
51 +
//        typeNumber = try? QRCodeType.typeNumber(of: text, errorCorrectLevel: errorCorrectLevel, encoding: encoding)
52 +
        self.typeNumber = model.typeNumber
52 53
        self.model = model
53 54
        self.text = text
54 55
        self.correctLevel = errorCorrectLevel

@@ -70,16 +70,7 @@
Loading
70 70
    /// Get the type by string length
71 71
    static func typeNumber(of text: String, errorCorrectLevel: QRErrorCorrectLevel, encoding: String.Encoding = .utf8) throws -> Int {
72 72
        
73 -
        let textLength: Int
74 -
        
75 -
        switch encoding {
76 -
            case .utf8:
77 -
                textLength = text.utf8.count
78 -
            case .utf16:
79 -
                textLength = text.utf16.count
80 -
            default:
81 -
                textLength = text.count
82 -
        }
73 +
        let textLength = text.lengthOfBytes(using: encoding)
83 74
        
84 75
        let maxTypeNumber = QRCodeLimitLength.count
85 76

@@ -30,14 +30,17 @@
Loading
30 30
    private let encodedText: QR8bitByte
31 31
    private var dataCache: [Int]
32 32
    
33 -
    init?(text: String, encoding: String.Encoding = .utf8, typeNumber: Int, errorCorrectLevel: QRErrorCorrectLevel) {
33 +
    init?(text: String, encoding: String.Encoding = .utf8, errorCorrectLevel: QRErrorCorrectLevel) {
34 34
        
35 35
        guard let encoded = QR8bitByte(text, encoding: encoding) else {
36 36
            return nil
37 37
        }
38 38
        
39 39
        self.encodedText = encoded
40 -
        self.typeNumber = typeNumber
40 +
        
41 +
        guard let newTypeNumber = try? QRCodeType.typeNumber(of: text, errorCorrectLevel: errorCorrectLevel, encoding: encoding) else { return nil }
42 +
        
43 +
        self.typeNumber = newTypeNumber
41 44
        self.errorCorrectLevel = errorCorrectLevel
42 45
        guard let dataCache = try? QRCodeModel.createData(
43 46
            typeNumber: typeNumber,
Files Coverage
Sources 93.74%
Project Totals (14 files) 93.74%
50.3
TRAVIS_OS_NAME=osx

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading