I wanna create a static array in my singleton GameManager class. Aim is filling out this array with coming questions from database and reach them from other classes.
Here is Question structure:
struct Question{ let levelId : Int32 let categoryId : Int32 let id : Int32 let question : String let fieldA : String let fieldB : String let fieldC : String let fieldD : String let answer : String init( categoryId : Int32, levelId: Int32,id : Int32,question : String,fieldA : String,fieldB : String,fieldC : String,fieldD : String,answer : String ) { self.categoryId = categoryId self.levelId=levelId self.id=id self.question=question self.fieldA=fieldA self.fieldB=fieldB self.fieldC=fieldC self.fieldD=fieldD self.answer=answer } }
It s the singleton Class
import Foundation class GameManager{ var Questions = [Question]() var categoryID = 0 var levelID = 0 var i = 0 { self.Questions = Questions[Question]// I create the static Question Array here, but it does not work self.categoryId = categoryId self.levelId=levelId self.id=id self.question=question self.fieldA=fieldA self.fieldB=fieldB self.fieldC=fieldC self.fieldD=fieldD self.answer=answer } static let sharedInstance = GameManager() }