我有兩個獨立的.swift文件。我想用ManagePerson.swift來管理我的Strings
,比如添加和檢索。另一個ViewController.swift創建一個用於訪問數據的ManagePerson類數組。Swift2的數組
在我ManagePerson.swift
func addPerson(name: String, code: String, description: String){
self.name = name
self.code = code
self.description = description
}
在我ViewController.swift。
var personList = [PersonTable]() // Declared at class level
for jsonObjectString in resultArray! {
let name = jsonObjectString["Name"] as! String
let code = jsonObjectString["Code"] as! String
let description = jsonObjectString["Description"] as! String
self.personList[count].addPerson(Name, code: code, description: description)
count++
}
但是,我似乎無法執行.addPerson
方法。我得到一個錯誤「主題:6:EXC_BAD_INSTRUCTION(代碼= EXC_I386_INVOP,子碼=爲0x0)」
謝謝!!!!!!! –