T9 is a predictive text technology for mobile phones (specifically those that contain a 3×4 numeric keypad). It allows the user to press a numerical key and form a set of keys. With this set of keys, T9 figures out exactly the word the user meant to type based on the list of valid words also called a dictionary. Here is exactly how T9 works: If the user wants to type a message to someone using a cellphone pad, they will only use the digits 2 through 9. The table below provides the corresponding letters for each digit:
import Contacts
import UIKit
fileprivate let T9Map = [
" " : "0",
"a" : "2", "b" : "2", "c" : "2", "d" : "3", "e" : "3", "f" : "3",
"g" : "4", "h" : "4", "i" : "4", "j" : "5", "k" : "5", "l" : "5",
"m" : "6", "n" : "6", "o" : "6", "p" : "7", "q" : "7", "r" : "7",
"s" : "7", "t" : "8", "u" : "8", "v" : "8", "w" : "9", "x" : "9",
"y" : "9", "z" : "9", "0" : "0", "1" : "1", "2" : "2", "3" : "3",
"4" : "4", "5" : "5", "6" : "6", "7" : "7", "8" : "8", "9" : "9"
]
var firstName : String!
var lastName : String!
var phoneNumber : String!
var t9String : String = ""
var image : UIImage?
var fullName: String! {
get {
return String(format: "%@ %@", self.firstName, self.lastName)
}
}
Comments
Leave a comment