Segmentation fault error on migration from SWIFT 2 to SWIFT 3

Viewed 153

Thoroughly searched for this question but was not able to find it in Stack Overflow.

Getting segmentation fault error:

1.  While type-checking getter for asset at <invalid loc>

Below is the code of the class for which I am getting Segmentation Fault -

import UIKit

class WidgetImageTableViewCell: UITableViewCell {

    @IBOutlet weak var imgViewWidget: UIImageView!

    var aspectConstraint : NSLayoutConstraint!
 {
        didSet {
            if oldValue != nil {
                imgViewWidget.removeConstraint(oldValue!)
            }

            if aspectConstraint != nil {
                imgViewWidget.addConstraint(aspectConstraint!)
            }
        }
    }

    override func prepareForReuse() {
        super.prepareForReuse()
        aspectConstraint = nil
    }

    func setPostedImage(image : UIImage) {

        let aspect:CGFloat = image.size.width/image.size.height
        aspectConstraint = NSLayoutConstraint(item: imgViewWidget, attribute: .width, relatedBy: .equal, toItem: imgViewWidget, attribute: .height, multiplier: aspect, constant: 0.0)

        imgViewWidget.image = image

    }

    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {

        super.setSelected(selected, animated: animated)
    }


}

Also, below is the screenshot of the stacktrace that I am getting while building - Stack trace image

0 Answers
Related