I've got a struct in my singleton class and I'm trying to set the values in a different class. I tried setting it like I'd set any other variable in the singleton class but i get an error "Static member 'bigStruct', cannot be used on instance of type "SharingManager" "
I tried -
let sm = SharingManager.sharedInstance
sm.bigStruct //Autocomplete doesn't work and i get an errorThen when I add line 15 in the singleton class, I can't set it because i get the error "Cannot assign to property: function calls immutable value" (From what i undertab this mens that it makes a copy of the struct so it can be viewed but not set)
sm.bigStruct.smallStruct.init().name = "my name"Singleton Class -
class SharingManager {
struct bigStruct {
struct smallStruct {
var name = String()
}//Small Struct End
} //Big Struct End
static let sharedInstance = SharingManager()
var big = bigStruct.self
}//Class End
I looked around somemore and tried this and it seems to work -
I added this to the singleton class
var big = SharingManager.bigStruct()
var small = SharingManager.bigStruct.smallStruct()Then to use it I just have to use -
let sm = SharingManager.sharedInstance
sm.small.name = "this is a name"
print(sm.small.name) //this printed the coorect value I just set