我似乎无法让我的数组被我的编码函数接受。我得到的错误是
“无法使用类型'的参数列表调用'encode'([String], forKey:[String])'
var billID: [String]=[]
var billNumber: [String]=[]
var billTitle: [String]=[]
var billDescription: [String]=[]
var lastAction: [String]=[]
var lastActionDate: [String]=[]
struct stateLawData {
static let state: String="state"
static let lastUpdate: String="lastUpdate"
static var billIDs: [String]=[]
static let billNumbers: [String]=[]
static let billDescriptions: [String]=[]
static let billTitles: [String]=[]
static let lastActions: [String]=[]
static let lastActionDate: [String]=[]
}
override func encode(with aCoder: NSCoder) {
aCoder.encode(stateAbbr, forKey: stateLawData.state)
aCoder.encode(lastUpdateTime, forKey: stateLawData.lastUpdate)
aCoder.encode(billID, forKey: stateLawData.billIDs)
aCoder.encode(billNumber, forKey: stateLawData.billNumbers)
aCoder.encode(billTitle, forKey: stateLawData.billTitles)
aCoder.encode(billDescription, forKey: stateLawData.billDescriptions)
aCoder.encode(lastAction, forKey: stateLawData.lastActions)
aCoder.encode(lastActionDate, forKey: stateLawData.lastActionDate)
}
这是在UITableViewController
中答案 0 :(得分:1)
所有键都需要是字符串。换句话说,您的所有静态stateLawData
变量都需要String
,就像前两个变量一样。