I am working on a final project for school, forgive me, I am having difficulty so I am trying to run in debug ... what am I doing wrong? I set my breakpoints and I run the simulator, for some reason the simulator starts up but my project closes ... I reopen it and it is obviously running, but there is nothing present in the console, even when run the code that should break on. Please help if you can, I am really getting frustrated because I can't get my code to work and now I cannot get my debug to work. Thank you in advance.
To see output in the "All Output" pane of the debugger, you need to call NSLog with a log string (which can be a format string with variables like printf). If you do not have any NSLog calls, then you should not expect to see any output in the debugger.
Related
Print something in console usually is fast (<1s) but recently I started working on a project and the print time is huge (>20s).
(for example putting a "Print("bla")" in the code will work fine, but printing through the console is slow)
Any ideas what might cause this?
This happens in Xcode 7,8 (and I don't remember if 9 also, but I think so). Also it's reproducible regardless of simulator/device.
This only happens for the 1st time I try to print, then it works fine.
My app has crashed telling that he index is out range when I use this team[1] which is surprising because it should have 2 strings in it. I have looked everywhere, in XCODE and the internet, but cannot find a way to see what the team array looks like. Is there anyway to see this? Thanks so much!
click on the left side of your line of code which contains (team[1]) to create a breakpoint.
Then run your app. When it reaches that point it will stop executing so you can check what is going on.
Here is an screenshot on how debugging looks like
You can see your array content in the "variables view"
There is also an example of "po" command on the "console" section
If you just want to use a breakpoint everytime your app crashes just add an exception breakpoint. This should show you where your code crashes and stop just before so you can find out what happened
I have a main ViewController. I then added an extension (custom keyboard), and made a KeyboardViewController. In the viewDidLoad() method, I have tons of functions that are 100% running, and working properly. If I try t print anything to console using print() it doesn't work however, and I am stumped as to why it wouldn't.
Assuming it might have something to do with extension?
use (lldb) and po to print or display anything you want to console.
In case anyone runs into this, the problem is that the logging is happening from the main app, one solution is to run the extension, and all the print logs work as expected. Otherwise, you can also change debug settings.
I am getting an EXC_BAD_ACCESS. I know what this usually means: Trying to access an object that doesn't exist (anymore) is the most likely cause.
So, where do I find that?
I have read numerous posts on the internet, and they all say:
"Enable NSZombie" in the scheme.
Now when I run the debugger, for what should I look? I can not see any difference...
Note: This is not about a perticular error in my code, but generally how to use the debugger with NSZombie enabled
What I would do it will be to locate a breakpoint just one line above the green arrow showing the EXC_BAD_ACCESS error. Then run again your code and reproduce the steps to generate the crash.
When you get to your breakpoint you can check that your objects are valid objects using right click and print description in the left side of your console within Xcode or typing the command 'po' within the console section in XCode. That's how I usually detect the errors.
Something useful is to trace the stack once the debugger stopped. It show in the left panel the threads and chain of invocations of the methods before the break point.
Hope this helps and hope my description of the alternative in how to track the error helps.
Write code in #synchronized(){} block.
Try this:
#synchronized (self){ //Your Code }
When I run my application it works well, but during transitions between its views I have a lot of CGContext errors in the console output, but the app still works well, no crashes or bugs I didn't see. Description: so I only run my app - all work well - but there appears error messages in the console:
And after any other view transition they appear again and again. So the question - how to fix this? And what may be the reason of this error messages? There a lot of views and code in my application so I don't even know what part is error-prone.But these messages appear after transitions between all views in my app. Thanks in advance.
Look for some method in your code where you call CGContextSaveGState, CGContextSetBlendMode, CGContextSetApha, etc. Chances are that you won´t find many places where you do that.
Well, if you find it, look for some statement (just before those listed in your console log) where a context is created, and try to understand why it fails. You may set a breakpoint on that line and inspect the parameters to the CGContextCreate call.
If you need more help, paste the code you have (hopefully) found.