Reputation: 196
I am trying using Xcode debug more efficiently. I realised some extra features which I have ever done before. From my understanding left side of debug console called String Summary ( please correct me if i wrong). I watched the WWDC videos but could not see the direct approaches to this section
var robGlobal = Player(name: "Rob", health: 10, energy: 10)
robGlobal.someFunction() // in viewdidload
struct Player {
var name: String
var health: Int
var energy: Int
func balance(_ x: inout Int, _ y: inout Int) {
let sum = x + y
x = sum / 2
y = sum - x
}
}
func someFunction() {
var robLocal = Player(name: "Rob", health: 10, energy: 10)
balance(&robLocal.health, &robLocal.energy) // put the breakpoint here
}
If I click the right click of the mouse; It appears an option "View memory of ... ". After next steps I added the screen shot and made 4 section to ask better question.
Q1: Why there is a 10 line ? 16F34BDA0 is obvious. it correspond to name but what about 16F34BDD7 second line and so on ?
Q2: Would you mind if you explain with detail section 1-2-3 ?
Q3: Also name and robLocal is showing same place in the memory ? Is that possible ? - then why health and energy has different ?
Upvotes: 2
Views: 191
Reputation: 25306
all of this is for the computer to read and is difficult for humans to understand. if you are trying to debug more efficiently, do yourself a favor and stay away from reading the binary in hex code and stick to the debugging bar at the bottom of the screen.
edit: you can find the memory locations of variables by clicking the 'i with a circle' on the String Summary. this should help you match up the memory locations in section 4 with the variables in the String Summary. Also if I were to guess, one of the memory locations were self, one robLocal, and one the program itself in memory being executed.
Upvotes: 1