Parcourir la source

Update examples to Swift 5

Nick Nallick il y a 6 ans
Parent
commit
29bbe8505f

+ 3 - 3
Examples/SwiftSerialExample/Sources/main.swift

@@ -32,9 +32,9 @@ do {
                            transmitRate: .baud9600,
                            minimumBytesToRead: 1)
 
-    print("Writing test string <\(testString)> of \(testString.characters.count) characters to serial port")
+    print("Writing test string <\(testString)> of \(testString.count) characters to serial port")
 
-    var bytesWritten = try serialPort.writeString(testString)
+    let bytesWritten = try serialPort.writeString(testString)
 
     print("Successfully wrote \(bytesWritten) bytes")
     print("Waiting to receive what was written...")
@@ -54,7 +54,7 @@ do {
     var multiLineString: String = ""
 
 
-    for i in 1...numberOfMultiNewLineTest { 
+    for _ in 1...numberOfMultiNewLineTest { 
         multiLineString += testString + "\n"
     }
 

+ 1 - 1
Examples/SwiftSerialIM/Sources/main.swift

@@ -113,7 +113,7 @@ do {
 
 
     while true {
-        var enteredKey = getKeyPress()
+        let enteredKey = getKeyPress()
         printToScreenFrom(myself: true, characterToPrint: enteredKey)
         var _ = try serialPort.writeChar(enteredKey)
     }