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
Related
I would like to easily check property values by typing them into the console (how it works in browser's console). It seems to not be possible. What are the alternatives for easy debugging of different property values instead of breakpoints?
You have to use breakpoints. there is no other options. breakpoints is something like debugger so put break point wherever you need and then when you reach at that breakpoint application will pause and If you simply take mouse curser over that line then also you can know the value of different properties.
you can use po command to print value of any property. write in console(beside lldb),
po then space and than property or variable name and you will get value of it.
You can use step over to go to next line and can use continue execution to continue through all breakpoints.
You can refer this tutorial. It is for old xcode but conceptually same with current.
Hope this will help :)
Type 'po propertyname' into the console and click enter.
In the console you can see the property values using po propertyName.
For view debugging, xcode provides view debugger as this image
No.
Closest thing is the console where you can look at variables and there is an option to look at an exploded view of you UI, where the classes and properties can be inspected. This is activated when you are running your app and click on the button with a hover-text "Debug View Hiererachy". You can find this button just above the console, to the left of the location icon.
I'm trying to track down a bug in an app which logs an error in the simulator, but doesn't crash in the simulator or on my testing device. I think I've got a handle on what to do once I can figure out where the problematic code is located, but I'm having a heck of a time figuring out what call is generating it.
CoreData: error: Failed to call designated initializer on NSManagedObject class "OneOfMyManagedObjects"
I'd like to add a breakpoint that stops execution on that error. How would I set the breakpoint navigator to stop execution when that error is logged in the console?
What I've Tried:
So far, I threw some log statements in AppDelegate.swift and the initial ViewController to "see what's going on". Additionally, I've thrown in some manual breakpoints in hopes of tracking down the issue that's generating the console error, but it's taking forever and a day to step through everything. Given the issue lives somewhere between AppDelegate and viewDidLoad of the initial ViewController, I'm baffled why it's taking me so long to spot the problem.
I've added an exception breakpoint for all exceptions in the breakpoint navigator, but this error doesn't appear to be enough to stop execution. I do think it's enough to cause a problem for a minority of users, which is why I'm trying to clean it up.
Special thanks to pbasdf for pointing me in the right direction.
My app uses a TabBarController with 4 tabs. The initial tab is tab 0, so I was looking for a problem between AppDelegate.swift and InitialVC's viewDidLoad. In reality, my problem lived on Tab3ViewController where OneOfMyManagedObjects are displayed.
I had a global variable set on Tab3ViewController that looked like this:
// this was the problem
var oneOfMyManagedObjectsToEdit = OneOfMyManagedObjects()
// I changed it to this and the error went away
var oneOfMyManagedObjectsToEdit: OneOfMyManagedObjects?
Thank you for pointing me in the right direction towards resolution of this problem.
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 }
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.
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.