4

in visual studio when i used to debug code with c++ std::vector i could see all the elements in it and even drill down to each element , somehow in Xcode 5.1 i can see this option
all i see is the iterators of the vector.

here is what i see in Xcode when i try to watch vector elements : std::vector how can i see the vectors elements in the debug window .

user63898
  • 29,839
  • 85
  • 272
  • 514
  • Well-formed question. Apple never has hit this well. For example, a `std::vector` (no reference) local automatic var is represented differently than a passed parameter (with or without reference). Even more aggravating, `std::vector`, where `MyClass` is simply `struct MyClass { std::string data; };` will do what you hope for (quite-similar to VS-watches), but not as a parameter; only as a local automatic var. I feel your pain, sir. – WhozCraig Aug 04 '14 at 20:03
  • You might also take a look at IntelliJ's AppCode - it support C++ on the Mac and I've used it to look at stl containers. – sfjac Aug 04 '14 at 20:13
  • yeah its just amazing , looks like only objC and now swift in xcode big problem if you like to do it with c++ and xcode,check my other question that has solved quickly only in VC++ http://stackoverflow.com/questions/25125657/xcode-5-1-call-stack-in-debug-show-only-thread-without-any-info-about-the-func – user63898 Aug 04 '14 at 20:17
  • Looks like it's a problem only for reference types (&). Try to go up the stack to the calling function and watch the value from there. – Michael Litvin Oct 22 '14 at 12:53

2 Answers2

1

For me (Xcode 6.0.1), this happens only with reference (&) types.

Try one of the following:

  1. Add a custom watch expression *&strLineOfChrsVec (dereference the address of the variable).
  2. Go up the stack and watch the original variable that you've passed to the function.
Michael Litvin
  • 3,976
  • 1
  • 34
  • 40
0

In order to temporarily see the values of a single element in the vector you can right click on it and then select:

Print Description of "[i]"

It will print to the output something like:

Printing description of *([1]): (std::__1::basic_string, std::__1::allocator >) [1] = "Hi"

where "Hi" was the value of the vector at position 1.

user3817808
  • 187
  • 1
  • 10