0

A variable in my code is being de-allocated somewhere, and i don't know where. I'm trying to debug it, but there is a lot of code to search through.

Is there a way to follow a variable, and show where it is being modified?

TheCodeArtist
  • 21,479
  • 4
  • 69
  • 130
hamza h
  • 355
  • 1
  • 4
  • 12
  • Is that variable accessed using a property? If so, override the setter and add a breakpoint into it. If it is not a property, make it one. Also make sure that all assignment is done via the setter. – Till Aug 20 '12 at 18:10
  • You could probably use conditional breakpoints. It is described here: http://stackoverflow.com/questions/988621/how-to-set-a-conditional-breakpoint-in-xcode-based-on-an-object-string-property – Mikael Aug 20 '12 at 18:13

1 Answers1

2

Right click on the variable in XCode's debugging window, and select "Watch variable".

Alternatively, use gdb: http://scottmcpeak.com/memory-errors/

This is discussed here in a similar topic: Tracking variable or memory change in Xcode?

Community
  • 1
  • 1
Kirby
  • 3,649
  • 3
  • 26
  • 28
  • That would be the **right** way of doing it. From my experience however, this failed a lot. Maybe I should give it another shot, now that gdb commonly isnt used anymore. – Till Aug 20 '12 at 18:13
  • doesnt seem to be working for me. after i clik on watch "variable" and then click on continue execution, i dont see the variable anymore.i need to figure out which line of code is resetting the variable to nil. variable is supposed to hold an AGSMapView – hamza h Aug 20 '12 at 18:38