swiftnscharacterset

Value of type CharacterSet has no member InvertedSet - Swift 3


I am trying to convert over swift 2 code to swift 3:

var customAllowedSet =  NSCharacterSet(charactersInString:"=\"#%/<>?@\\^`{|}").invertedSet

It throws this error:

Value of type CharacterSet has no member InvertedSet

Solution

  • According to Apple documentation the name of invertedSet method in Swift 3 was changed to just inverted. So try this:

    var customAllowedSet =  CharacterSet(charactersIn:"=\"#%/<>?@\\^`{|}").inverted
    

    PS: init(charactersInString:) of CharacterSet also changed to init(charactersIn:)