Segmentation Failure Error When Switching from SWIFT 2 to SWIFT 3

I carefully looked for this question, but could not find it in Stack Overflow.

Getting segmentation failure error:

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

Below is the class code for which I get 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 a screenshot of the stacktrace that I get when I create it - Image of a stack trace

+5
source share

Source: https://habr.com/ru/post/1270711/


All Articles