Вот мой код. Я новичок в использовании Swift, и мой код не работает.
Показана ошибка в контроллере представления:
Невозможно присвоить значение типа 'Int' типу 'String'
И:
Невозможно привести значение типа '__NSCFNumber' (0x104061840) к 'NSString' (0x1031324a8). 2019-09-30 01: 46: 05.056249 + 0900 Сообщество [20037: 815002] Не удалось преобразовать значение типа '__NSCFNumber' (0x104061840) в 'NSString' (0x1031324a8).
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// getting index of the cell wherein comments button has been pressed
let indexPathRow = (sender as! UIButton).tag
// accessing segue we need -> CommentsVC
if segue.identifier == "CommentsVC" {
// accessing destination ViewController -> CommentsVC
let vc = segue.destination as! CommentsVC
// assigning values to the vars of CommentsVC
vc.avaImage = avaImageView.image!
vc.fullnameString = fullnameLable.text!
vc.dateString = posts[indexPathRow]!["date_created"] as! String
vc.textString = posts[indexPathRow]!["text"] as! String
////////////
// sending id of the post
vc.post_id = posts[indexPathRow]!["id"] as! Int
// sending the image to the CommentsVC
let indexPath = IndexPath(item: indexPathRow, section: 0)
guard let cell = tableView.cellForRow(at: indexPath) as? PicCell else {
return
}
vc.pictureImage = cell.pictureImageView.image!
}
Невозможно присвоить значение типа Int типу String
on:
vc.post_id = posts[indexPathRow]!["id"] as! Int