Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Build a Self-Destructing Message iPhone App Relating Users in Parse.com Adding the Edit Friends Screen

App Crashing When I Select "Edit" in friends tab.

So I followed the video exactly, because I am on Xcode 5 I had to add a bit of code:

  • (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIndentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIndentifier forIndexPath:indexPath];

    PFUser *user = [self.allUsers objectAtIndex:indexPath.row]; cell.textLabel.text = user.username;

    return cell;

The app builds successfully, but when I click "Edit" it crashed and in green highlights the line:

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIndentifier forIndexPath:indexPath];

I have set the prototype cell to "Cell" and it still crashes....

Any help would be greatly appreciated!

Thanks,

Dylan

Any suggestions? Ben Jakuben :)

does the console output any error messages?

Ben Jakuben
Ben Jakuben
Treehouse Teacher

Sounds like you have everything set up correctly. If you are certain that the prototype cell has the correct identifier and everything is hooked up correctly, then try a complete uninstall, clean, and rebuild of your project to make sure the latest code base is in fact being used. If you still have a problem, zip up your project and send it to help@teamtreehouse.com and ask them to forward it to me. I can perhaps help you troubleshoot from there.

7 Answers

Hmmm. I went back and looked at my project, and it too had the lines as you described them. Have you tried replacing your files with the completed files from treehouse or reviewing treehouse's completed versions?The next episode should have the Edit Friends files implemented, you can review those to see where you may have missed some step. I'll have to watch the video again to review.

  • (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

    PFUser *user = [self.allUsers objectAtIndex:indexPath.row]; cell.textLabel.text = user.username;

    if ([self isFriend:user]) { //cell.accessoryType = UITableViewCellAccessoryCheckmark; cell.accessoryView = [MSCellAccessory accessoryWithType:FLAT_CHECKMARK color:APP_PURPLE]; } else { //cell.accessoryType = UITableViewCellAccessoryNone; cell.accessoryView = nil; }

    return cell; }

Dylan,

If you are using storyboard for this app, then you need to set the cell indentifier in storyboard. User the Attribute Inspector and set the "Identifier" field to your cell resuse identifier "Cell". The line of code creating a string called cell identifier does not look correct to me. You are creating a reuse identifier in the method for selecting a row.

static NSString *CellIndentifier = @"Cell";

2014-05-11 15:54:06.737 Ribbit[18902:60b] Current User: dylan 2014-05-11 15:54:11.250 Ribbit[18902:60b] *** Assertion failure in -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:], /SourceCache/UIKit_Sim/UIKit-2935.137/UITableView.m:5439 (lldb)

Yep, that is an issue with your cell identifier alright. Were you able to set it in storyboard and resolve your issue?

Hi Dennis,

Yep i checked it in the storyboard and it is all linked up, but still crashes.

I haven't changed any code as of yet ... it's identical to that of the video ...

Dylan

Thanks guys. I am currently working on the Instagram project and will go back to this and see if I can figure it out once I have finished this project. Thanks for the offer Ben, I will take you up on it if I get stuck!

Addison Francisco
Addison Francisco
9,561 Points

I had the same issue, I swore it was correct, and I had no errors from Xcode, but alas...I had 1 letter lower case. I had

cellforRowAtIndexPath:(NSIndexPath *)indexPath

Instead of

cellForRowAtIndexPath:(NSIndexPath *)indexPath