1

When I call dequeueReusableCellWithIdentifier it is freezing my code and does never return any cell (or nil) I change the code from my custom class to a UITableViewCell to be sure the problem wasn't in my class, I also create a brand new empty cell to call with the identifier.

I add a log before and after the call for dequeueReusableCellWithIdentifier as you can see in the screenshot the one before gets called once and the one after never.

enter image description here

I try to clean and build, clean the project folder, delete DerivedData, restart the computer. I can't see any exceptions or what is really holding the code.

Any suggestions?

Adrian
  • 16,233
  • 18
  • 112
  • 180
Icaro
  • 14,585
  • 6
  • 60
  • 75
  • It might not change anything to your problem, but I'm not sure you're using `dequeueReusableCellWithIdentifier` right. It should be returning an Optional cell but you're force-casting it to an explicitly unwrapped cell (the `as! UITableViewCell` part). Try removing the cast and adding and `if (cell == nil) { ... }` check after that to instantiate a new cell if the dequeue operation returned `nil` (which is impossible with your current code). – Romain Aug 08 '15 at 23:19
  • I try that too it also does not return nil – Icaro Aug 08 '15 at 23:27
  • Are you using storyboards? If you already registered the cell identifier `"cellOverview"` somewhere in your storyboard, you could try using the newer method, which guarantees returning a cell (non-Optional). Try this if you're using storyboards: `let cell = tableView.dequeueReusableCellWithIdentifier("cellOverview", forIndexPath: indexPath)` – Romain Aug 09 '15 at 07:40
  • I think that it has nothing to do with dequeuing the cell. something else is freezing your thread. – hasan Aug 09 '15 at 12:20
  • In my case the this queation solved the problem http://stackoverflow.com/questions/32611789/uitextview-with-text-less-than-10-characters-hangs-ios-9 – user3836066 Dec 16 '15 at 05:39
  • In my case the this question solved the problem http://stackoverflow.com/questions/32611789/uitextview-with-text-less-than-10-characters-hangs-ios-9 – user3836066 Dec 16 '15 at 05:42

2 Answers2

0

I am not sure what happened to XCode, but, if someone find the same problem here is what I had to do.

I didn't find anything wrong with the cell (yes I was using storyboard and the identifier was set correctly) and noting was wrong with the code in the custom class as well. I even went to the point of create a secondary custom class and custom cell and it did not help, so I try to put a invalid identifier and even there XCode did not return me an error (as it should).

I had to delete my custom cell from the storyboard, as soon as I did that all start to work again, first the error that the identifier didn't exist, than the temporary one start to work, than I recreate the original one (exactly as before) and all start to work again.

Very overkill but worked for me. Thanks for all the help!

Icaro
  • 14,585
  • 6
  • 60
  • 75
  • I'm having the same kinda problem. All is set fine. Even 10 more prototype cells are loading fine, only one is doing the problem. I checked identifier text for typos etc. Tried cleaning project too. But nothing happens.. :( – Chanchal Raj Sep 29 '15 at 14:02
0

It is expressed that you are printing println("return dequeueReusableCellWithIdentifier"), but can't see your return cell code at the end of your function, that must conform to your function expectation.

Marco
  • 314
  • 4
  • 9
  • well it is bellow and you cannot see in the screenshot, however there is two points here, first and more important the code wouldn't compile if I wasn't return a cell as it is required for the function, second we need to agree that: to get to the return statement the line of code println("return dequeueReusableCellWithIdentifier") MUST be executed first. – Icaro Aug 12 '15 at 22:45
  • Try like this: `let cell: UITableViewCell = self.tableView.dequeueReusableCellWithIdentifier("cellOverview") as UITableViewCell!`. By the way, what Xcode are you using? I found some difference unwrapping optionals depending on the Xcode version. – Marco Aug 13 '15 at 00:07