1

I set a breakpoint immediately following these lines:

NSInteger index = [self.aCombobox indexOfSelectedItem];
NSString *nameSelected = [self.names objectAtIndex:index]; 

If I then roll the mouse over nameSelected, it shows a value of “nil.” And if I type “po nameSelected” in the debugger console, it says the string “does not appear to point to a valid object.”

So I added an NSLog to print nameSelected, which duly printed the string. And, once debugger is below the NSLog line, if I roll the mouse over nameSelected, it shows the correct value.

Is there some reason why the debugger behaves this way? It makes it harder to identify where the real problem is.

KevinDTimm
  • 14,226
  • 3
  • 42
  • 60
Wienke
  • 3,723
  • 27
  • 40
  • 2
    You're definitely building a debug build, not a release build? – Tommy Dec 02 '10 at 17:24
  • I was doing a release build. That was the problem. Since the debugger seems to work the same for iPhone apps running on the device as for the simulator, I didn’t think the build choice would make a lot of difference for Cocoa debugging, either. The following link set me straight: http://stackoverflow.com/questions/761628/xcode-cocoa-what-are-the-differences-between-debug-and-release-builds – Wienke Dec 03 '10 at 02:21

3 Answers3

2

Me (and millions of other iOS developers) do this all the time and have no issues. Though it seems a stupid query, have you made modifications to the source while debugging (specifically, added lines of code)? If so, the debugger is still pointing to line X from the .o file while your source is out of sync.

KevinDTimm
  • 14,226
  • 3
  • 42
  • 60
1

The real answer is Tommy's comment to this old question of mine. It was a Xcode newby mistake. Sorry to have left this hang out there so long,

Wienke
  • 3,723
  • 27
  • 40
0

Actually, our experience is that the iOS enabled GDB is buggy as anything. We've observed these kinds of bugs quite often. There might be a solution, but most of the time we just sucked it up and resorted to NSLog Debugging.

Blitz
  • 5,521
  • 3
  • 35
  • 53
  • OK, yes, I wondered if it might really be a bug -- but since most of the time the mistakes are my own, I thought I might be missing something, say a setting in Xcode prefs. Good to know I'm not crazy. NSLog it is, then. – Wienke Dec 02 '10 at 17:29
  • 1
    Having been a professional iOS developer for a couple of years, I've seen maybe three bugs in GDB. I don't think this is the correct answer. – Tommy Dec 02 '10 at 17:31