1

I have a TableVC which has categories when you tap on one it takes you to the items within it. But when I do this I get the following grouping of multiple errors when the app crashes:

1.

error initializing newrealm, Error Domain=io.realm Code=1 "Provided schema version 0 is less than last set version 1." UserInfo={NSLocalizedDescription=Provided schema version 0 is less than last set version 1., Error Code=1}

2.

2018-08-01 12:56:06.152225-0400 Todoey[35380:4690261] Unknown class SwipeTableViewCell in Interface Builder file.

3.

Could not cast value of type 'UITableViewCell' (0x1096e3580) to 'SwipeCellKit.SwipeTableViewCell' (0x106d231d0).

4.

2018-08-01 12:56:06.153831-0400 Todoey[35380:4690261] Could not cast value of type 'UITableViewCell' (0x1096e3580) to 'SwipeCellKit.SwipeTableViewCell' (0x106d231d0).

I have followed the steps laid out in many previous questions but no luck

This is where I get a -Thread 1: signal SIGABRT-

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! SwipeTableViewCell
    cell.delegate = self
    return cell
}

Help please

enter image description here

Marmoy
  • 8,009
  • 7
  • 46
  • 74
  • 1
    Set the class of the table view cell in Interface Builder to `SwipeTableViewCell` – vadian Aug 01 '18 at 17:12
  • I have... I set SwipeTableViewCell as the class for both VC's that have Cell's in them to it. –  Aug 01 '18 at 17:37
  • It did not work tho –  Aug 01 '18 at 17:55
  • It seems that the class is located in another module `SwipeCellKit`. If so you have to select the module in IB, too. – vadian Aug 01 '18 at 17:58
  • I have not been able to find the module, SwipeCellKit. But I'm not sure I understand what you are saying –  Aug 01 '18 at 19:26
  • I just read the error message `SwipeCellKit.SwipeTableViewCell` means `SwipeTableViewCell` of module `SwipeCellKit` – vadian Aug 01 '18 at 19:30
  • Ok so I understand what your saying now, but how do I select the module in IB? –  Aug 01 '18 at 19:48
  • Below the popup to specify the class. – vadian Aug 01 '18 at 19:50
  • I did as you said for both Cell's, but still does not work. Is this what you meant? CHECK IMG. I ADDED TO QUESTION. –  Aug 01 '18 at 19:58
  • I fixed it but don't know how... it just started working after I redid the name of the class and module. Xcode issue I guess –  Aug 01 '18 at 22:21

3 Answers3

8

all you have to do, select your tableViewCell -> go to identity Inspector -> select the custom class as SwipeTableViewCell and module as SwipeCellKit. then run...

select the tableview cell

here select the custom class name and module

salma209
  • 189
  • 2
  • 6
1

I think you are overriding the registration of cell to your table view, with the method:

@available(iOS 6.0, *)
    open func register(_ cellClass: AnyClass?, forCellReuseIdentifier identifier: String)

and somewhere in viewDidLoad, or viewDidAppear, or viewWillAppear you registered to tableView a simple UITableCell.self instead a custom cell, as bellow :

self.tableView.register(UITableViewCell.self, forCellReuseIdentifier: "Cell")

In case you create the SwipeTableViewCell programatically use this method in viewDidLoad as bellow:

self.tableView.register(SwipeTableViewCell.self, forCellReuseIdentifier: "Cell")

In case your SwipeTableViewCell is created in storyboards, I don't recommend to use this method, because you override the constructor, and your objects inside the SwipeTableViewCell need to be initialized programatically. Just remove the registration line, because in the storyboard you have registered the custom cell. Take care to have set identifier for cell.

Lirik
  • 3,167
  • 1
  • 30
  • 31
Ion Timotin
  • 71
  • 1
  • 3
0

Although it is not in the question, I encountered the same problem on the same tutorial, so same app. This might help some future passersby.

It should work with:

let cell = tableView.dequeueReusableCell(withIdentifier: "CategoryCell", for: indexPath) as! SwipeTableViewCell

It WILL NOT work with:

let cell = UITableViewCell(style: .default, reuseIdentifier: "CategoryCell") as! SwipeTableViewCell

okihand
  • 45
  • 3