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

Ryan Sommers
Ryan Sommers
1,528 Points

BlogReader unrecognized selector sent to instance

Hi there,

I just finished the BlogReader project, but when I run it in the Simulator and click a table cell to load the web view, it crashes with the error "-[SBTableViewController setBlogPostURL:]: unrecognized selector sent to instance"

Depending on which code I'm using, the breakpoint goes to:

[segue.destinationViewController setBlogPostURL:blogPost.url];

or

wbc.blogPostURL = blogPost.url;

I downloaded the Treehouse project files and it runs fine. I tried looking through it to find whatever bad code I had but everything looked okay, so then I just copied all the code (everything but the Storyboard) from Treehouse's files to my files, changed the class names to match what I was using, and still got the same error.

Any ideas?

Amit Bijlani
Amit Bijlani
Treehouse Guest Teacher

From the error it looks like you are trying to set the blogPostURL on the wrong view controller. It says SBTableViewController when it should be the view controller that contains your web view.

Ryan Sommers
Ryan Sommers
1,528 Points

Thanks Amit, that helped.

Finally figured out I'd entered the wrong custom class in the IB on the view controller. Wasn't seeing that field because I kept clicking in the IB which selected children rather than the parent view controller.

1 Answer

Amit Bijlani
STAFF
Amit Bijlani
Treehouse Guest Teacher

From the error it looks like you are trying to set the blogPostURL on the wrong view controller. It says SBTableViewController when it should be the view controller that contains your web view.

Edit: moved down to the answer instead of comment.