Home / IOS Development / android – Read / write file in kotlin native – IOS page

android – Read / write file in kotlin native – IOS page



I want to create a file and type in with Kotlin / Native on the ** IOS page **.

I have this code:

FellesHoved:

expect class ReadWriteFile

In androidHoved:

actual class ReadWriteFile {
    fun read(path : String, filename: String) : Boolean {
        val file = File("$path/$filename")
        return if(file.exists()) {
            file.forEachLine {
                // do something
            }
            true
        } else {
            false
        }
    }

    fun save(path : String, filename : String, nbLine : Int) {
        val file = File("$path/$filename")
        val w = file.writer()
        for(it in 1
..nbLine) { w.write("write somethingn") } w.close() } }

I iosMain:

actual class ReadWriteFile {
    fun read(path : String, filename: String) : Boolean {
        ???????????
    }

    fun save(path : String, filename : String, nbLine : Int) {
        ???????????
    }
}


Source link