iOS Swift keyCommands Reading Numbers Only -


please consider following code:

override var keycommands: [uikeycommand]? {     var commands:[uikeycommand] = []      let numbers = ["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]     number in numbers {         let txt = number string         commands.append(uikeycommand(input: txt, modifierflags: [], action: #selector(keypressed(_:))))     }     commands.append(uikeycommand(input: "\r", modifierflags: [], action: #selector(enterpressed)))     return commands } 

for reason numbers getting read. bluetooth barcode scanner emulates keyboard. keycommands not capable of reading alpha characters or doing wrong?

thanks eric aya able working. below modified code. may not elegant solution works:

 override var keycommands: [uikeycommand]? {     var commands:[uikeycommand] = []      let numbers = ["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]      number in numbers {         let txt = number string         if int(txt) == nil {             commands.append(uikeycommand(input: txt, modifierflags: [uikeymodifierflags.shift], action: #selector(keypressed(_:))))         } else {             commands.append(uikeycommand(input: txt, modifierflags: [], action: #selector(keypressed(_:))))         }     }     commands.append(uikeycommand(input: "\r", modifierflags: [], action: #selector(enterpressed)))     return commands } 

Comments

Popular posts from this blog

many to many - Django Rest Framework ManyToMany filter multiple values -

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

Java Entity Manager - JSON reader was expecting a value but found 'db' -