이 오류가 발생합니다.
스레드 1 : EXC_BAD_INSTRUCTION (코드 = EXC_I386_INVOP, 하위 코드 = 0x0)
나는 선택 사항을 강제로 풀었다는 것을 의미합니다. 그러나 문제는 다음 코드 줄에서 발생한다는 것입니다.
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell") as! TableViewCell //This is the problem
let object = self.fetchedResultsController.object(at: indexPath)
cell.nameLabel.text = object.title
if let imgURL = object.imageURL {
let realURL = NSURL(string: imgURL)
let data = NSData(contentsOf: (realURL as URL?)!)
cell.imgView.image = UIImage(data: data! as Data)
}
return cell
}
그래서 내 생각에는 클래스를 Cell이나 식별자에 할당 할 때 실수를했지만 두 번 확인한 결과 맞았습니다. 다른 문제가 무엇인지 잘 모르겠습니다. 먼저 테스트하기 위해 다른 프로젝트 템플릿 (블로그 리더 기능)에서 코드를 만든 다음 코드를 복사했습니다 (작동 중입니다). 그래서 그것이 그 출처가 될 수 있는지 확실하지 않습니다. 문제.
내가 무엇을 할 수 있는지에 대한 아이디어가 있습니까?
* TableViewCell 내부의 코드입니다.
import UIKit
import CoreData
class TableViewCell: UITableViewCell {
@IBOutlet weak var imgView: UIImageView!
@IBOutlet weak var nameLabel: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
이 줄을 사용하여 셀을 대기열에서 빼십시오.
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! TableViewCell
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다