Cannot use mutating member on immutable value of type

后端 未结 6 1311
被撕碎了的回忆
被撕碎了的回忆 2021-01-01 09:04

I have following struct:

public protocol SuperModel {
    // empty protocol
}
struct ModelOne: SuperModel {
    struct SubModelOne {
        var someVar: Dou         


        
6条回答
  •  伪装坚强ぢ
    2021-01-01 09:34

    First downcast the self.data to ModelOne then call setSub function

     if var data = self.data as? ModelOne {
       data.setSub(ModelOne.SubModelOne(someVar: 2, othervar: 1))
     }
    

提交回复
热议问题