serdar aylanc
serdar aylanc

Reputation: 1347

swift - Custom TableViewCell has no initializers

I am getting "Class 'FavArticleTableViewCell' has no initializers" error for my tableviewcell.

I have several Custom TableViewCells, this the only one I get this error.

import UIKit
import CoreData

class FavArticleTableViewCell: UITableViewCell {

    @IBOutlet weak var avatarImageView: UIImageView!

    var context: NSManagedObjectContext? {
        get {
            let appDel = UIApplication.sharedApplication().delegate as! AppDelegate
            let _context = appDel.managedObjectContext
            return _context
        }
    }

    var article:Article {
        didSet{
            self.setupFavArticle()
        }
    }

    func setupFavArticle(){

    }
}

Upvotes: 0

Views: 320

Answers (1)

Bannings
Bannings

Reputation: 10479

You have a named article variable that does not have default value. But all variables must have an initialized value in Swift except Optional.

Declare the article as Optional will remove the error:

var article:Article? {
    didSet{
        self.setupFavArticle()
    }
}

Upvotes: 1

Related Questions