What is the equivalent of swift’s [ ] in kotlin. ...
# ios
p
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
h
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.
d
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
or
options = 0u
If there were multiple options available, such as maybe when options is typed as
UNAuthorizationOptions
then use the
.or
to combine the options, like this:
Copy code
options = UNAuthorizationOptionSound
    .or(UNAuthorizationOptionAlert)
    .or(UNAuthorizationOptionBadge)
🙌 1
p
Thanks a lot @hfhbd @Darron Schall This was really informative.