0

Can't seem to figure out why I'm getting this error.

I've attached two pieces of code below, any help is very appreciated

    private func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: IndexPath) -> UITableViewCell {
    var cell = self.tableView.dequeueReusableCellWithIdentifier("postCell", forIndexPath: indexPath) as! PostTableViewCell <--- error is with this line
    let post = self.posts![indexPath.row]
    let user = post["user"] as? PFUser
    let caption = post["caption"] as! String?

    if let photo = post["media"] {
        let imagePFFIle = photo as! PFFile
        imagePFFIle.getDataInBackground(block: {(imageData: Data?, error: Error?) -> Void in
            if error == nil {
                if let imageData = imageData {
                    let image = UIImage(data:imageData)
                    cell.photoView.image = image
                    cell.usernameLabel.text = user?.username
                    cell.usernameLabel2.text = user?.username
                    cell.captionLabel.text = caption
                }
            }
        })
    }
    //print("Image exists - Home View Controller")
    //print("\(posts!.count)")
    return cell
}

classes from Main.storyboard

 <tableView clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" restorationIdentifier="" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" reuseIdentifier="postCell" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="QKL-F5-RQ0" customClass="PostTableViewCell">
                            <rect key="frame" x="0.0" y="71" width="375" height="596"/>
                            <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                            <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                        </tableView>
Tom
  • 13
  • 3

1 Answers1

0

It's possible that PostTableViewCell isn't part of the right target. Select the file in the navigator, open the right pain and select File Inspector. Make sure that the main target is checked. See example below:enter image description here

dktaylor
  • 874
  • 7
  • 12