I'm developing a native app for iOS and Android and i noticed something different that intrigued me. This is not an issue or a bug, maybe only a different behaviour on different platforms, but i'd like to understand why and if i'm missing something.
Let's suppose there are 2 Android activities:
Activity1 starts Activity2 and using intents bundle assign its model to Activity2 model
Controller1 starts Controller2 and using segues assign its model to Controller2 model
On iOS you pass the object by reference to the new VC. So if you change a property of that object in the second VC, that change is visible to the first VC because it is the same object.
On Android when you pass objects via a
Bundle they are serialized and deserialized which can create a new object, thus the change is not visible in the original
Activity. When passing
Parcelable data between fragments they can be passed by reference and the change is visible in the original
EDIT: In Java/Android objects are passed by value, not by reference, thus when you assign a new object into a variable the old one is not changed in the original fragment. But if you change its internal state (e.g. property/field), then this is reflected in the original fragment.