Error: unrecognized selector

Posted on 2013-08-28
Medium Priority
Last Modified: 2013-08-29
I'm taking a course online, and working through my very first IOS project.

Topic: Buttons and IBaction

when stepping through the project to create an IBaction for my button. I notice the code in the training video was different than the code my xcode generated when dragging a button from the storyboard to the viewcontroller.

So I deleted the code that I generated from the veiwcontroller.h and .m file and started the process over again.  

Ever since I deleted the code,  the program will not work.  In the simulator when I click my button i get an error.

I tried doing a clean build (command-option-shift-k) that did not work.  I deleted the code again, and ran it through the simulator and when I click the button it still crashes.

I know if I delete the project and start over it would work.  But I am more interested in finding what went wrong and how can I fix this solution in the future.

I attached the error message.
Question by:mmsi
  • 3
  • 2
LVL 33

Expert Comment

ID: 39447937
When Xcode generated a code for you - an method that is called when the user clicks on the button - this IBAction, it connected the button you see on the screen with your project (visually there was a dot before text '- IBAction'). You deleted the code but you didn't deleted the connection points. When you added a new method, probably, you didn't connect it with the
button on the screen. You can do it and it will fix your current project.

Maybe, at this stage, it can be easier and faster to re-create the project and do everything again.

Author Comment

ID: 39448803
I was playing around with the project, and realized that if I could just delete the button the button off the storyboard.

Question: Where are the connection points that you mention?

For example: C#

If I drag a button to the form and create a click event.  Visual Studio generates EventHandlers for me.  So If I delete the click event, then compile the program crashes.  I would then just delete the EventHandler that visual studio created, and then recompile the error would go away.

Is this a similar situation?  Where xcode is creating some kind of connection, that I can just delete and the error would go away?  I deleted the code I generated, but I am not sure why the error is occurring when the code is gone.
LVL 33

Accepted Solution

pgnatyuk earned 2000 total points
ID: 39448899
Not exactly.
Objective-C is a dynamic language - almost everything happens in the run-time (In C# the compiler checks everything)

I hope you already know about a storyboard and about the xib-files. These connections are there. You work with these file in Interface Builder. Here you can delete this connection: select this button and in the connection inspector you will the connection - Touch Up Inside should be connected with a method - I attached a screenshot. If you see it, click on the cross.

Author Closing Comment

ID: 39449477
Thank you, this is the solution I was looking for.
LVL 33

Expert Comment

ID: 39449975
You are welcome

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

I recently went through the process of creating an installable image of an iPhone mobile app (an .ipa file) that beta testers could load onto their test devices. The process involved quite a few steps, but both Appcelerator and Diawi.org had decent …
It’s time for spooky stories and consuming way too much sugar, including the many treats we’ve whipped for you in the world of tech. Check it out!
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video tutorial shows you the steps to go through to set up what I believe to be the best email app on the android platform to read Exchange mail.  Get the app on your phone: The first step is to make sure you have the Samsung Email app on your …

600 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question