1

I can't seem to get my arrays to be accepted by my encode function. The error I am getting is

"Cannot invoke 'encode' with an argument list of type '([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)
}

This is within a UITableViewController

1 Answer 1

1

All keys need to be strings. In other words, all of your static stateLawData variables need to be String, just like the first two.

Sign up to request clarification or add additional context in comments.

4 Comments

What happened after you fixed all of the keys?
It appears so. Will let you know if that changes.
Glad to help. Don't forget to accept answers that solve your issues. This lets people know the problem is solved.
@RussJ I see you unaccepted the answer. Did this not solve your issue?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.