When I declare a list taking nullable items in Kot...
# ios
b
When I declare a list taking nullable items in Kotlin:
Copy code
fun myFunc(list: List<*>?): List<*>
// OR
fun myFunc(list: List<Any?>?): List<Any?>
The iOS (Swift) definition is
func myList(list: [Any]?) -> [Any]
(not nullable items). Is this a known issue? Any workaround?
n
Yes, it’s a limitation of Objective C “generics”
s
It's actually an ObjectiveC thing. NSArray and NSDictionary can't contain null values. It’s one of the few times that the language cares about when a value is null.
😢 1
🆒 1
👍 1
b
I see, guess that won't be fixed unless there is true Swift interop in the future. For now I guess I'll just have to use a magic value to represent a "KotlinNull" and then swap it back to null on the Kotlin side or something 🤷‍♂️
n
@Brian Guertin sounds like
NSNull
👆 1
👀 1