Iām running through the Tutorial in Swift 3.0, Xcode 8. Having an issue with grabbing the image. Iāve gotten the rest of the project working with Swift 3 and Alamofire 4.
import UIKit
import Alamofire
class DefinitionViewController: UIViewController {
@IBOutlet weak var imageView: RoundedImageView! @IBOutlet weak var titleLabel: UILabel! @IBOutlet weak var descriptionLabel: UILabel! @IBOutlet weak var activityIndicator: UIActivityIndicatorView!
var definition: Definition!
override func viewDidLoad() {
super.viewDidLoad()
title = definition.title
descriptionLabel.text = definition.description
if let imageURL = definition.imageURL {
Alamofire.request(imageURL).response {
response in
self.activityIndicator.stopAnimating()
let image = UIImage(data: response) <----ERROR HERE
self.imageView.image = image
}
}
}
override var preferredStatusBarStyle : UIStatusBarStyle {
return .lightContent
}
}
Iām getting the error, "Cannot convert value of type āDefaultDataResponseā to expected argument type āDataā
I have scoured the internet and Iām having trouble finding a solution to this. Thanks. P.S. Total beginner here.
Hi, you need to add a little:
if let imageURL = definition.imageURL {
Alamofire.request(imageURL).response { response in
self.activityIndicator.stopAnimating()
if let data = response.data,
let image = UIImage(data: data) {
self.imageView.image = image
}
}
}
Hi, I have notice that the size of my project increases because of the .frameworks generated from the Cartfile. Do you think its necessary to keep all the files and folders generated by the Cartfile build in the project? For instance I notice some files like A.framework.dSYM (symbol files I believe), do I need these files in my project as they all contribute to the .ipa size.
I get the following error when trying to run the app after inserting the framework:
dyld: Library not loaded: @rpath/Turbolinks.framework/Turbolinks
Referenced from: /Users/hugohyz/Library/Developer/CoreSimulator/Devices/.../Test1.app/Test1
Reason: image not found
(lldb)