https://kotlinlang.org logo
#ios
Title
# ios
a

Arkadii Ivanov

11/14/2023, 9:17 PM
Is there a reason why I can't override didMoveToParentViewController for in a Kotlin implementation of
UIViewController
? There is only
platform.UIKit.UIViewController.didMoveToParentViewController
extension function.
To override this function, you can do as we did in #data2viz for
drawRect
in `UIKit`'s `UIView`: https://github.com/data2viz/data2viz/blob/5640d3e8f1ce4cd4e5d651431726869e329520fc/viz/src/nativeinterop/cinterop/uikit.def
a

Arkadii Ivanov

11/14/2023, 11:49 PM
Thank you! I will try that!
r

ribesg

11/15/2023, 2:31 PM
Can't you just annotate your function with
@ObjCAction
in that case?
a

Arkadii Ivanov

11/15/2023, 2:34 PM
Thanks @ribesg, I will try that as well. The possible issue I believe is that we should call super, right?
r

ribesg

11/15/2023, 2:36 PM
Well Apple's documentation does not say that
a

Arkadii Ivanov

11/15/2023, 2:38 PM
I usually assume that we should always call super, unless documented otherwise. 😁
r

ribesg

11/15/2023, 2:38 PM
I usually don't assume that the super function needs to be called unless the documentation says so
a

Arkadii Ivanov

11/15/2023, 2:38 PM
Lol)
r

ribesg

11/15/2023, 2:38 PM
🙂
I never used that function, but last time I checked for 2 other functions the super implementation were empty
l

louiscad

11/15/2023, 2:39 PM
How do you check the super implementation on closed source iOS?
r

ribesg

11/15/2023, 2:40 PM
You find some guy on the internet stating it doesn't do anything, then you try it and nothing breaks when you just not call super because you don't know how to, then you just roll with it
l

louiscad

11/15/2023, 2:41 PM
Lovely workflow, that is something only Apple could do 😍
r

ribesg

11/15/2023, 2:41 PM
🍎 🥊
😆 2
But really, if the super function does something, but your testing shows no issue when you're not calling super, then it doesn't really matter if it does something or not. You're on iOS, having things work is already an achievement
🏆 1
a

Arkadii Ivanov

11/15/2023, 2:43 PM
But even if we could see the code, it could still be different on different versions. There may even be a minor system update which adds code to super.
r

ribesg

11/15/2023, 2:44 PM
Exactly, so why bother anyway. Apple will make updates that will fuck up everything anyway.
Just try it and if it works it works