Here I am encoding my string but it gives an error stated above. What I had done is:
let plainData = (password)?.data(using: String.Encoding(rawValue: String.Encoding.utf8.rawValue))
let base64String = plainData.base64EncodedStringWithOptions(NSData.Base64EncodingOptions.init(rawValue: 0))
It gives me an error on the second line of code. If anyone can help!
You need to use base64EncodedString()
function of NSData.
let base64String = plainData?.base64EncodedString()
This works with Swift 3.0
Actually with update of swift version it gives an error. We can do something like:
let plainData = (password)?.data(using: String.Encoding(rawValue: String.Encoding.utf8.rawValue))
let base64String = plainData?.base64EncodedData(options: NSData.Base64EncodingOptions.init(rawValue: 0))
It solved my problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With