Hello, I have a class in Kotlin with methods such...
# kotlin-native
t
Hello, I have a class in Kotlin with methods such as
Copy code
class MyClass {
    private val arrayQueue = ArrayQueue<String>()

    fun save(item: String) {
        arrayQueue.add(item);
    }

    val last: String
        get() = arrayQueue.last()
}
I use it in objective C
Copy code
+ (instancetype)sharedInstance {
    static NativeClass *nativeClass = nil;
    static dispatch_once_t onceToken;

    dispatch_once(&onceToken, ^{
        nativeClass = [[NativeClass alloc] init];
        nativeClass.myClass = [[MyClass alloc] init];
    });

    return nativeClass;
}
First of all, accessing it was an issue just to get
.last
, so I created a wrapper to get a frozen version.
Copy code
fun getMyClass() = MyClass().freeze()
But by doing this, I cannot mutate it anymore
kotlin.native.concurrent.InvalidMutabilityException: mutation attempt of frozen
How can I overcome this kind of issue?
Hmm, the class needs to be frozen, but I can use mutable field with IsolateState