Your Second Kotlin Android App - Part 18: Parcels | Ray Wenderlich

Parcels are another way to pass data which is useful for packaging objects.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/4534-your-second-kotlin-android-app/lessons/18

“constructor(source: Parcel) : this(source.readString(), source.createStringArrayList())”

gives me a Type Mismatch:
“Required String, Found String?”

Nevermind, I figured it out. Had to make the val name nullable and cast createStringArrayList

hope everything still works


class TaskList(val name: String?, val tasks: ArrayList = ArrayList()) : Parcelable {

constructor(source: Parcel) : this(source.readString(),
    source.createStringArrayList() as ArrayList<String>
)

I’m glad to hear you were able to work through it. Honestly, those make for the best learning experiences.