I am getting a few errors using Swift, and when I have tried the solutions listed on other Stack Overflow posts, I get additional errors. The first error I get is NSForwarding: warning: object 0x7dc4ca30 of class 'h2.Items' does not implement methodSignatureForSelector: -- trouble ahead Unrecognized selector -[h2.Items initWithCoder:]
I've then updated my code to add "NSObject" and when I do that I get the following error:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[h2.Items initWithCoder:]: unrecognized selector sent to instance 0x79069250'
I'm not sure where to go from here. I have been following the tutorial on http://shrikar.com/blog/2015/01/17/uitableview-and-uitableviewcell-customization-in-swift/
and tried the solutions from Got Unrecognized selector -replacementObjectForKeyedArchiver: crash when implementing NSCoding in Swift
Does anyone have any additional suggestions?
My code is:
import CloudKit
import UIKit
import Foundation
class Items: NSObject
{
class Entry
{
var filename : String
init(fname : String)
{
self.filename = fname
}
}
var pics = [
Entry(fname: "circle.png")
]
}
Here is the code that is calling that class:
var items = Items()
override func viewDidLoad() {
super.viewDidLoad()
}
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return items.pics.count
}
override func tableView(tableVIew: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as TableViewCell
let entry = items.pics[indexPath.row]
let image = UIImage(named: entry.filename)
cell.anotherSelfie.image = image
return cell
}
}
and here is the code for the cell:
class TableViewCell: UITableViewCell {
@IBOutlet var anotherSelfie: UIImageView!
override func awakeFromNib() {
super.awakeFromNib()
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
}