UITableView won't see custom UITableViewCell

I just made a second UITableViewCell class, and my table view won't see it when I try to instantiate it! Here's my cell class:


import UIKit

class RecordingCell: UITableViewCell {
    
    
    @IBOutlet var titleLabel: UILabel!
    var title : String = ""
    
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
        title = titleLabel.text!
        
        titleAnimation()
        
    }
    
    
    
    func titleAnimation(){
        print ("starting the animation function")
        UIView.animate(withDuration: 1.5, delay: 1.5, options: .curveEaseInOut, animations: {
            
            self.titleLabel.text! = "Recording in Progress"
    
        }, completion: nil)
    }
}


It's super simple and just something I'm playing with. And here's how I'm filling the table view:


func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        
        if videoURLS.count == 0{
            selectButton.isEnabled = false
            let cell = tableView.dequeueReusableCell(withIdentifier: "emptyCell")
            return cell!
        }
            
        if tableView.numberOfRows(inSection: 0) == (videoURLS.count + 1){
            if indexPath.row == 0{
                let cell = self.tableView.dequeueReusableCell(withIdentifier: "recordingCell") as! RecordingCell
                return cell
            }
            if indexPath.row != 0{
                selectButton.isEnabled = true
                let cell = self.tableView.dequeueReusableCell(withIdentifier: "videoCell") as! VideoCell
                cell.videoURL = videoURLS[indexPath.row - 1]
                cell.parent = self
                cell.setViews()
                cell.setString()
                cell.setDate()
                cell.setTitle()
                cell.setSize()
                cell.setJpg()
                return cell
            }
        }
        else{
            selectButton.isEnabled = true
            let cell = self.tableView.dequeueReusableCell(withIdentifier: "videoCell") as! VideoCell
            cell.videoURL = videoURLS[indexPath.row]
            cell.parent = self
            cell.setViews()
            cell.setString()
            cell.setDate()
            cell.setTitle()
            cell.setSize()
            cell.setJpg()
            return cell
        }
    }


At line 11 it shows the error "Use of undeclared type RecordingCell." I've tried resetting the target in the cell class, but it still doesn't work.

Replies

The utilities tab is the window on the right side. I'd like to make the settings the same, but there's no way I can see how. I'll do more research and post what I find.

Do you get that simple error in the Build Log?

You should better clarify it's File Inspector of the Utility pane.


Usually, for source files, On Demand Resource Tags shows Only resources are taggable and cannot be edited.

Are you sure you can set the On Demand Resource Tags for VideoCell.swift? Then your Xcode project may be completely broken...

Bruce is probably speaking of the xib file, which is taggable.

A very good point. Bruce has never written RecordingCell.swift nor VideoCell.swift when writing about the File Inspector...

You're right, sorry. It's in the File Inspector.


I went through the other files in my project, and it's inconsistent if I can tag the file or not. If my project is completely broken, what can I do to fix it?

You could delete the suspected files and recreate them completely (text could be copied / pasted).


Take care not to keep connections.

I came up with at least a temporary solution! I merged the two classes in one swift file! It works!

Congratulations. But the solution seems really temporary, as you said adding a new file did not work.


You may need to create a brand-new project, and copy source files and resource files one by one. You should better check if your project does compile at each a fiew steps. (Of couse you may need to temporarily comment out some codes or add stub codes.)


And when you find something wrong, you need to rollback to the older state. Are you using Git for your project?


This may be caused by a bug of Xcode, or you may have mistakenly touched internal project files.

Or it may be caused by a Pod you are using. Even if it hasn't caused any issues till now , it may be the cause of the issue now.

I have read several reports that some mal-configured Pods break Xcode projects, better check the community site of the Pod.

You kept the 2 classes but just merged the files ? It is very strange. Does it mean that the RecordingCell file was just corrupted, hence not visible to compiler ? However, you said it saw errors introduced ; hence it was seen. Pretty strange.