0

I am using Xcode 5.0.2, iOS7. I use a Navigation Controller and Table View.

I changed Table View "Content" from Dynamic Prototypes to Static Cells, then it is crash. Before crash, APP running OK. Please, help. Thank you.

Assertion failure in -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:], /SourceCache/UIKit/UIKit-2903.23/UITableView.m:5261

2013-12-11 23:04:12.952 Wop[9339:60b] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier Cell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'

* First throw call stack:

(0x30cdfe83 0x3b03c6c7 0x30cdfd55 0x316880af 0x335d015f 0x240bf 0x33596315 0x3353e6cd 0x3353def1 0x33464353 0x330ea943 0x330e6167 0x33115425 0x334e118f 0x334df7f9 0x334dea37 0x334de9bf 0x334de957 0x334d7459 0x3346a397 0x334de6a9 0x334de17d 0x3346f581 0x3346cae5 0x334d782d 0x334d45fd 0x334ceb41 0x33469a07 0x33468cfd 0x334ce321 0x3594e76d 0x3594e357 0x30caa777 0x30caa713 0x30ca8edf 0x30c13471 0x30c13253 0x334cd5c3 0x334c8845 0x23d71 0x3b535ab7)

libc++abi.dylib: terminating with uncaught exception of type NSException

(lldb)

12/15 12:37 add I am so sorry for ask this similar question, this is my first time to learning language, I don't know what the keyword should I type.

H.B.U
  • 23
  • 4
  • Have you added cell identifier? and do you pass the same identifier as parameter of dequeueReusableCellWithIdentifier:@"HERE PASS IDENTIFIER"forIndexPath: – Greg Dec 11 '13 at 15:33
  • @Greg Do you mean this? - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; – H.B.U Dec 11 '13 at 15:46
  • not even an Xcode question... –  Dec 11 '13 at 15:47
  • The cellForRowAtIndexPath method is only needed for tableviews using dynamic prototypes so you should delete the method from your view controllers .m file. – asjj Dec 11 '13 at 15:50
  • @Lyssa Can you say it clearer, please!Thank you. – H.B.U Dec 11 '13 at 16:05
  • @H.B.U I've posted an answer with some more explanation. – asjj Dec 11 '13 at 16:07

1 Answers1

1

When creating a view controller than inherits from UITableViewController the following methods are already included:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

If you are not using Dynamic Prototypes then these methods aren't needed and should be deleted.

When your tableview is loading it is calling cellForRowAtIndexPath (if numberOfSectionsInTableView and numberOfRowsInSection are returning a number that isn't 0) which is trying to create a cell with an identifier of "Cell". It can't find a prototype cell with this identifier because you have set the table to use static cells instead and so you get the exception.

asjj
  • 543
  • 5
  • 19
  • YESSSSS, Thank you so much. It is useful. It work. But the cell item name is gone... how do I do for save it?check:http://imgur.com/1mS1wqW – H.B.U Dec 11 '13 at 16:33
  • Can you see the item names in the storyboard? – asjj Dec 11 '13 at 16:36
  • Can't. http://imgur.com/vAYgjDi – H.B.U Dec 11 '13 at 16:53
  • You need to add the item names to your cells in the storyboard. Your cell style is currently set to 'Custom' so you can drag a UILabel onto each cell and type in your item name. Or you could set each cell's style to one of the preset such as 'Basic' and change that text instead. – asjj Dec 11 '13 at 16:58
  • 1
    WWWWOOOOOO, I am so surprise it is so easy, amazing. Anyway, it is work. Thank you so much. http://imgur.com/8RuFxgO – H.B.U Dec 11 '13 at 17:13