First, a tip about posting code: use the <> button in the toolbar at the top of post editor. You can paste your code, highlight it, then click the button, or click the button, then paste your code in the code area (in Safari, use Edit > Paste and Match Style).
If your initializer has parameters, then you have to give it some parameters when you call it. I'm not sure why you are passing in i, j, and k if you are just setting them to zero. However, if you want just one instance of the data that is shared among all your view controllers, you shouldn't be calling the initializer from each view controller anyway. I was imagining something like this:
class Pick {
var pickerSizes: Array<String>!
var pickerGrades: Array<String>!
var pickerProducts: Array<String>!
var i: Int = 0
var j: Int = 0
var k: Int = 0
init() {
self.pickerSizes = self.laodSizes()
self.pickerGrades = self.loadGrades()
self.pickerProducts = self.loadProducts()
}
func loadSizes() -> Array<String> {
// your code to load the sizes from core data
}
func loadGrades() -> Array<String> {
// your code to load the grades from core data
}
func loadProducts() -> Array<String> {
// your code to load the products from core data
}
func saveAll() {
// your code to save the arrays to the core data source
}
// all your other code for this class
}
let globalPick = Pick() // an instance is created (initializer runs) when the app starts.
class MyViewController: UIViewController {
// all your outlets, properties, etc. defined
override func viewDidLoad() {
// examples of using globalPick; could be anywhere in your functions for this class
self.someProperty = globalPick.pickerSizes[2]
globalPick.pickerGrades.append("New Grade")
globalPick.k = 23
globalPick.saveAll()
}
}
class AnotherViewController: UIViewController {
// all your outlets, properties, etc. defined
override func viewDidLoad() {
// examples of using globalPick; could be anywhere in your functions for this class
self.someProperty = globalPick.pickerProducts[7]
globalPick.pickerSizes.append("New Size")
globalPick.i = 10
globalPick.saveAll()
}
}