What is the equivalent of swift’s [ ] in kotlin. ...
# ios
What is the equivalent of swift’s [] in kotlin. I am trying to use public init?(base64Encoded base64String: String, options: NSData.Base64DecodingOptions = []) But in kotlin [] converts into ULong. Is there any way i can achieve the same behaviour of [] from kotlin
It’s not related to [], but the optionset uses bitshifting under the hood and to objective c it’s only a unsigned long, mapping to ULong. So in Kotlin you have to shift the bits yourself.
🙌 1
But if you only need the empty option set, use 0.
To expand a little on what Philip said... there's really only one option per https://developer.apple.com/documentation/foundation/nsdatabase64decodingoptions?language=objc so it's either
options = NSDataBase64DecodingIgnoreUnknownCharacters
options = 0u
If there were multiple options available, such as maybe when options is typed as
then use the
to combine the options, like this:
Copy code
options = UNAuthorizationOptionSound
🙌 1
Thanks a lot @hfhbd @Darron Schall This was really informative.