exc_bad_instruction(code=exc_i386_Invop subcode=0x0) xcode - ios

I am using xcode with the language swift. I continue to get this error on all of my code. exc_bad_instruction(code=exc_i386_Invop subcode=0x0) xcode. I have seen other questions and none make sense. I'm not sure if it is because of the second view but here is the code.
enter image description here
It has two views so I don't know if thats the problem. I need help!

Seems like the iboutlet is not connected in storyboard, because of which it is not getting initialised, no memory allocated to this object. Kindly check your storyboard connections.

Related

Getting random crashes while pushing to another view controller

I am getting random crashes while pushing to another view controller.

It was too difficult to find out such a crash, we spent the almost 2-3 days to solve this issue. seems like the crash was due to the one extra view outlet got connected to the main view in the storyboard. Which created the nil reference for some objects of the view controller and applications crashes.
But something surprising to us that how Xcode allowing me to connect the two outlets to the main view. I have again tried connecting the same but this time it is not allowing me to connect.  Attaching the screenshot for the same.

Any kind of help/explanation is appreciated.
Please add crash logs. We should check them. Theres any data moving between two ViewControllers
It is problem with Xcode sometimes while editing the outlets.Find the controller on which app crashes and reconnect the outlets and run again.I don't know the exact reason but that solve my problem.

App crashes in AppDelegate and cannot get past launch screen

The app crashes in AppDelegate, unable to get beyond the launch screen. No view controller code ever gets executed.
The stack trace is also not very helpful nor is the line highlighted in AppDelegate when the crash occurs.
Images below provide the details.
How to debug from here?
Check any IBOutlet links carefully; you may have deleted the property from your view controller but the UI element is still connected to it. This should give you an exception stating something like Class ViewController is not key value coding-compliant for key XXX where XXX is your bad IBOutlet, however Swift's exception reporting does seem to be a bit hit-and-miss at times.
Here's another possible cause related to the reason Paulw11 stated that may help someone else.
If you have segue's in your storyboard that links to a storyboard reference in another bundle, and you change the name of the bundle where the reference resides, make sure to update the Bundle name in your storyboard for the linked reference.
I have a framework I'm developing that contains some storyboards and UI components. I decided to rename the framework, updated the podfile references in the app and all the file imports to reflect the new framework name but completely forgot that there were storyboard references in the app referencing view controllers provided in storyboards in the framework.
Here's an example:
If you do not rename the reference you will experience a crash when you try to load the storyboard containing your link with no hint as to why. I spent an embarrassing amount of time hunting this down.

Rendering Video using XCDYouTubeKit and swift

Please bear with me as I have been trying to program in iOs using swift for a week now and at the moment I am stuck on an error. I need some insight with what is wrong with what I am doing.
Screenshot of Storyboard and .swift file
Screenshot of my error
I am gonna guess you have resolved it. Usually that error comes when you deleted an IBOutlet from the interface side of code but you still have it left behind in the the storyboard. Delete the "test" IBOutlet from the storyboard and that should fix it.

Weird crash while navigating back

My app crashes randomly when navigating back in a NavigationController. Here is what I know:
It happens randomly (sometimes, I can come back once or twice and if I reload the viewController and press "back" again it will crash)
It happens even with an empty ViewController (I tried to comment out all my code in ViewController.h and .m and to remove all the outlets links)
Nothing shows up in the debug console, only a EXEC_BAD_ACCESS is shown in main.m
I spent the afternoon on this and tried everything.
I don't include code right now because I have no idea where to look. As I said, it even happens with an empty ViewController.
Any thoughts or similar experience ?
EDIT:
Yes I tried to add an exception breakpoint
I even tried to find some observer issues with Spark debugger.
EDIT 2:
Actually, the ViewControllers were not that empty. The import on an UIView category was the problem. Check my answer below.
It's difficult to say exactly what could be causing it without more information, but in my experience the most common reason for an EXC_BAD_ACCESS is when someone tries to call a selector on a deallocated instance. This issue can be a lot easier to debug if you enable zombie objects.
Edit Scheme -> Diagnostics -> Enable Zombie Objects
Now instead of getting a bad access exception you should get a more helpful "message sent to deallocated instance" error (assuming that's actually the problem), along with what method was being called on which class of object.
The problem was that some of my views were importing a custom UIView category that included a dealloc method. I deleted the dealloc method from the category and everything is fine now.

Is it possible that NSZombie doesn't point out EXC_BAD_ACCESS with ARC?

i'm currently working on an ios project with some people, one of us decided to use ARC in a part of the app.
Unfotunatly, we are currently experiencing some crashes when coming back from background.
Here are the steps we follow to crash the application, we perform them with the ios-simulator:
start the application
get on a ViewController A (coded with ARC)
get on a ViewController B (not coded with ARC -to be honest i don't
know if it's relevant-)
put the application in background.
simulate a memory warning (thx to the simulator)
start again the application, we'll be on the ViewController B
go back on the Viewcontroller A
the application crashes pointing the main function with an
EXC_BAD_ACCESS
We did try to use NSZombieEnabled to YES, but when we do it, the application doesn't crash and keeps running perfectly, so we wonder if it might be possible that NSZombieEnabled doesn't work well with ARC?
if anyone could give me a quick and clear insight about ARC and NSZombieEnabled that would be apreciated, i think i know how all of it works, but apparently i must be missing something.
Thanks anyway for your help and time.
Better than using the NSZombieEnabled, you should Profile the project, and use the Zombie instrument. When you do the same thing it should stop and say "zombie messaged", where you can click an arrow to see the class that is a zombie, and where it was allocated/deallocated.
I don't think the crash has to do with ARC, instead in viewDidUnload you are deallocating something, and then not setting a reference to nil - when you come back it tries to use the invalid reference.
Probably you would be better off if everything used ARC as it really helps to cure issues like this (the bug is very likely in the non-ARC code).

Resources