Search code examples
swiftxcodeswift3

Swift 3 conversion : value of type 'characterset' has no member 'characterIsMember'


I am currently converting my codes to swift 3 and i encounter the above mentioned error with the following codes.

 func containsAlphabets() -> Bool {
    //Checks if all the characters inside the string are alphabets
    let set = NSCharacterSet.letters
    return self.utf16.contains( { return set.characterIsMember($0)  } )
}

Any kind souls can assist on this?


Solution

  • edit/update: Xcode 11.4 • Swift 5.1

    extension StringProtocol {
        var containsLetters: Bool { contains { $0.isLetter } }
    }