I am trying to add multiple card views through storyboard. I link the up to code with IBOutlet and add the title view and detail view. Once i run the app and go to the CardViews, the app crashes giving me the "Thread 1:EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)" The first CardView (grammarCard) works fine but the second does not (vocabCard).
Here is the code
import UIKit
import Material
class StudyViewController: UIViewController {
@IBOutlet weak var vocabCard: CardView!
@IBOutlet weak var grammarCard: CardView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
// Grammar Card Title
let gTitleLabel:UILabel = UILabel()
gTitleLabel.text = "Grammar"
gTitleLabel.textColor = MaterialColor.deepPurple.darken1
grammarCard.titleLabel = gTitleLabel
// Grammar Card Detail
let detailLabel: UILabel = UILabel()
detailLabel.text = "Learn"
detailLabel.numberOfLines = 0
grammarCard.detailView = detailLabel
// Start button
let button: FlatButton = FlatButton()
button.pulseColor = MaterialColor.deepPurple.lighten1
button.pulseScale = false
button.setTitle("Start", forState: .Normal)
button.setTitleColor(MaterialColor.deepPurple.darken1, forState: .Normal)
// Adding Buttons
grammarCard.rightButtons = [button]
//THIS ONE IS FINE
// Do any additional setup after loading the view.
// Vocab Card Title
let vTitleLabel:UILabel = UILabel()
vTitleLabel.text = "Vocabulary"
vTitleLabel.textColor = MaterialColor.deepPurple.darken1
vocabCard.titleLabel = vTitleLabel // Here the issue pops up
// Vocab Card Detail
let vdetailLabel: UILabel = UILabel()
vdetailLabel.text = "Learn the words of "
vdetailLabel.numberOfLines = 0
vocabCard.detailView = vdetailLabel // Here the issue pops up
// Start button
let vbutton: FlatButton = FlatButton()
vbutton.pulseColor = MaterialColor.deepPurple.lighten1
vbutton.pulseScale = false
vbutton.setTitle("Start", forState: .Normal)
vbutton.setTitleColor(MaterialColor.deepPurple.darken1, forState: .Normal)
// Adding Buttons
vocabCard.rightButtons = [vbutton]
}
Thank you so much in advanced!