Menu
  • HOME
  • TAGS

Using binary operator with unichar and String

ios,swift,binary-operators,unichar

Since unichar is a type aliased to a 16-bit integer, you need to "wrap" it in UnicodeScalar function for the comparison: if UnicodeScalar(character) == "1" { //do this thingy } ...

Unichar variable in Swift

swift,unichar

In Swift, the character literals are of type Character. let exclamationMark: Character = "!" See Strings and Characters For advanced readers: You can also extend unichar with the capability to accept character literals: extension unichar : UnicodeScalarLiteralConvertible { public typealias UnicodeScalarLiteralType = UnicodeScalar public init(unicodeScalarLiteral scalar: UnicodeScalar) { self.init(scalar.value) }...