Hi,
I am now dealing with a string of instructions that been feed by a text field.
the problem is, why this code doesn’t work? ‘instruction’ prints the string value I want to use correctly corresponding to the statement, but I always get the “wasn’t a recognized character” default case…
func processInputCommand() {
        print("processing called")
        let string = self.robotInstructions.text!
        let commands = Array(string.characters)
        let instruction = String(describing: commands.last)
        print(instruction)
            switch instruction {
            case "N" :
                self.usersRobot.yPosition = self.usersRobot.yPosition + 1
            case "S" :
                self.usersRobot.yPosition = self.usersRobot.yPosition - 1
            case "E" :
                self.usersRobot.xPosition = self.usersRobot.xPosition + 1
            case "W" :
                self.usersRobot.xPosition = self.usersRobot.xPosition - 1
            case "P" :
                pickUpGummyBears()
            case "D" :
                if self.usersRobot.numberOfBagsHeld > 0 {
                    dropGummyBears()
                } else {
                    print("THE ROBOT ISNT HOLDING ANY BAGS CURRENTLY")
                }
            default:
                print("WASNT RECOGNISED CHARACTER")
            }
    }