开发者

Debugger falsely shows object as nil until object has been used

开发者 https://www.devze.com 2023-01-28 05:45 出处:网络
I set a breakpoint immediately following these lines: NSInteger index = [self.aCombobox indexOfSelectedItem];

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 开发者_C百科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.


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.


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,


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消