PDA

View Full Version : How can I normally watch maps in Xcode?




Dmitry(RUS)
Feb 16, 2012, 06:07 AM
When I want to watch map, I see a lot of unclear folders.But I only want to see keys and values, is it possible?

Thank You.



KnightWRX
Feb 16, 2012, 06:17 AM
A screenshot of what you mean ? And what is the type of variable you're trying to watch ? Objects are complex and thus watching one will return a complex structure compromised not only of the value of the instance variable you want, but of all its instance variables.

In any case, when you collapse the objects in the debugger, it should give you some idea of the values (for an NSString, it should show you the actual string, for an NSDictionary, the number of key/pairs, for an NSArray, the number of elements in it).

Dmitry(RUS)
Feb 16, 2012, 06:41 AM
Variable "a" is map<string, int>, respectively I want to watch "a".

This is screenshot:
http://narod.ru/disk/40915871001/%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%202012-02-16%20%D0%B2%2016.24.02.png.html

To download enter numbers ans click green button, then click the link.
I'm sorry I do not know normal site to place photos.

KnightWRX
Feb 16, 2012, 07:55 AM
You don't need a normal site to place photos, just attach them to your forum post. Under the textbox to enter the text for a forum post, you have an "Additional Options" section. The 2nd sub-section is "Attach Files". Just click "Manage Attachments" and upload your screenshot.

Sorry if I'm reluctant to click on any .ru website, I just can't do it.

gnasher729
Feb 16, 2012, 08:39 AM
When I want to watch map, I see a lot of unclear folders.But I only want to see keys and values, is it possible?

Thank You.

If you had said std::map, then people would know what you are talking about. Remember: We can't read your mind.

Get the latest XCode version, then try debugging with either gdb or lldb, and pick whichever gives better results.

Dmitry(RUS)
Feb 16, 2012, 08:39 AM
So, here it is.

gnasher729
Feb 16, 2012, 08:41 AM
So, here it is.

Well, there is node_count = 0. What else do you expect in an empty std::map? And of course the debugger shows you the implementation details of std::map.

Dmitry(RUS)
Feb 16, 2012, 08:43 AM
I want to see keys too.I now there is nothing there, but when there is something, how can I watch it?

PS
I'm a beginner in Xcode, and I'm not from English-speaking country, so do not judge strictly.

gnasher729
Feb 16, 2012, 10:35 AM
I want to see keys too.I now there is nothing there, but when there is something, how can I watch it?

PS
I'm a beginner in Xcode, and I'm not from English-speaking country, so do not judge strictly.

std::map is what it is called in C++. I highly recommend using the full names in C++ code and when you talk about it.

And how can you look at a std::map when it isn't empty? Well, you try it. Set a breakpoint a bit later after you assigned to it. Or, just for experimenting, add something in your code and set a breakpoint, to try it out. Then you have the choice between two debuggers. And finally, you can add code that prints the contents of the map.