"unrecognized selector" which does not exist - objective-c

I hit a problem in an iPhone app where it crashes, displaying the following message in the debugger console:
2012-08-31 12:31:24.628 test_app[1672:207] -[My_ViewController
tapDetected:]: unrecognized selector sent to instance 0x7621ef0
The strange thing is that "tapDetected" does not even exist anymore in my code for this class. It used to be a method, but it has been removed and replaced by a different one.
I noticed though that when I look at the .xib file, in the first responder, "tapDetected" still appears in the list.
But I don't know if this has anything to do with my problem or not, and I do not see any way to remove it.
Any idea or suggestion about this issue will be welcome.

Remove tapDetected: method from .xib from where it is calling.

Open your .xib file. Select the button in your .xib file which generated the error. Select Show Utilities=>Click on Connection Inspector=>Check the Sent Events list. Remove the connection to tapDetected: if exits.

This could be because the button in xib (which i am guessing gives the error when pressed) is still connected to the method..in ur xib file..just delete that connection from the connection inspector list for that button..

I want to add that when you deal with interface builder stuff and xib files, sometimes your app can also crash regardless of making sure you deleted something from your xib file.
I learnt that this was cause because the previous copy of the app on the simulator is somehow "caching" the xib contents.
The fix was to delete the instance of the app from the simulator or device, then re-run the app again.

Related

App doesn't launch after adding a method (Xcode 7.2)

I'm new to Cocoa and Mac programming so sorry if this is a bad question,but I got frustrated and I don't know what to do. Heres my ViewController files (Appdelegate.h and .m is left untouched to default)
Up to this point everything works as expected, App compiles and runs without a problem. but when I start adding some logic to a method updateDetailViews I get this:
How to fix it?
You can run your application removing the blue arrow. (Use drag and drop to remove).
It is use to check your function is called or not while your application is running. So when it call your application stop running and show this line. You can run again using the play type button from console.

XCode crashes on start up

Yes, this happens to people. Yes, I've looked at all the solutions.
This is different.
XCode starts and there is no error message, it just freezes. This is the screen I get:
That's it. No errors. I can't interact with it, I can't close it. The only thing I can do is use Show All Windows. There are five and yes I don't need them all (never did! don't know why I have them) but I can't close any of them. To get rid of it I need to do a hard reset.
I've tried deleting the library file in Finder as this was one of the solutions.
Nope.
Anyone any ideas?
I think it's XCode 6 (the latest) but I can't tell because I can't access the menu.
I ended up scouring Stackoverflow for ways to clear the startup process.
You hold cmd+shift when you start XCode - ONLY from the task bar, this does NOT work if you go into the Applications folder - and it will load blank.
Then you can load your project.

NSWorkspace selectFile:inFileViewerRootedAtPath: does not work the first time it is called

I have a sandboxed Cocoa app. I noticed that when I call [[NSWorkspace sharedWorkspace] selectFile:path inFileViewerRootedAtPath:path] no Finder window opens the first time is called. Finder.app is brought to the foreground (menu bar changes to Finder), but otherwise nothing happens.
When I bring my app back to the front and again have it select a file in Finder, the Finder window opens with the file selected as expected. I tried this with #"" as second argument, same thing.
When a Finder window is open already, everything works as expected.
Has anybody else seen this problem? Workaround is to immediately call selectFile:... twice, but that doesn't seem right.
Edit: not related to sandboxing. Same issue without sandbox.
I think activateFileViewerSelectingURLs is better. It correctly selects multiple files in the finder.

How can I locate the line causing a crash in Xcode4.2 with iOS5?

When I use Xcode4.1 with iOS4, it works fine.
But when I use Xcode4.2 with iOS5, it locates at the main method.
So I don't know where in the program caused the crash.
You can set a breakpoint for all exceptoins
Command+6
Click + on the bottom left
Add Exception Breakpoint
Click Done
I am not sure why they changed the old behavior.

NSWorkspace openFile: randomly brings focus back to my app

Within my Cocoa app, I call NSWorkspace's openFile: method to open some file with its default application.
Sometimes this works just fine, and the other application gets focus, as it should.
But alas, sometimes (the occurrence of which seems to be totally random), after the focus goes briefly to the other application, it goes quickly back to my Cocoa app. This is unwanted.
Any ideas what the causes could be?
Note: I have also tried the openFile:withApplication:andDeactivate:, passing YES to the last argument. This doesn't work either. The strange random occurrences of focus going back to my Cocoa app persist.
I'm unable to reproduce this now. Not sure what the problem was.