0

Does anyone know how to get the value for class member variable in IOS ?

I try to use LLDB to debug NSArray in class member variable.

After I run this

__cellDataShadowArray2D = [[NSArray alloc] initWithObjects:[NSArray arrayWithObjects:obj1, obj2, nil], nil];

When I check the value using LLDB (print object), I always get this.

(lldb) po __cellDataShadowArray2D
(NSArray *) $66 = 0x001e8894 <object returned empty description>

(lldb) p __cellDataShadowArray2D
(NSArray *) $67 = 0x001e8894

(lldb) po [__cellDataShadowArray2D count]
2012-04-24 10:10:38.535 SOME [61985:15803] -[__NSCFConstantString count]: unrecognized selector sent to instance 0x1e8894
(id) $68 = 0x00000000 <nil>

(lldb) po [__cellDataShadowArray2D retainCount]
(id) $69 = 0xffffffff [no Objective-C description available]

(lldb) p (int) [__cellDataShadowArray2D retainCount]
(int) $70 = -1

(lldb) p (int) [__cellDataShadowArray2D count]
2012-04-24 10:11:31.333 SOME [61985:15803] -[__NSCFConstantString count]: unrecognized selector sent to instance 0x1e8894
(int) $71 = 0
7
  • Are you using lldb immediately after doing the alloc? Is it possible that the object has been deallocated? Commented Apr 24, 2012 at 0:22
  • Also, what is the type of __cellDataShadowArray2D ? Commented Apr 24, 2012 at 0:29
  • 1
    What do you mean by "class member variable?" There are no class variables in ObjC. Do you mean an instance variable? Or a static variable? Commented Apr 24, 2012 at 0:50
  • Note that po is for printing objects as you discover - no point using it for [foo retainCount], which returns an NSUInteger Commented Apr 24, 2012 at 0:52
  • 2
    My strong suspicion is that you haven't actually run the assignment line. It's behaving as though it's pointing at random memory. Are you certain that the assignment has run? Is __cellDataShadowArray2D defined as a strong variable? Commented Apr 24, 2012 at 0:53

3 Answers 3

1
  • make sure the line of code is actually evaluated before doing the test.

It is clear that __cellDataShadowArray2D is pointing to an empty instance of a compiled constant string; @"". That means it cannot be an over-release or anything like that; it means that the assignment has not yet happened (or you are attempting to debug optimized code and the debugger is confused due to optimizations).

  • po of non-object types doesn't make sense

  • retainCount is useless. Don't call it.

Sign up to request clarification or add additional context in comments.

Comments

0

This may help: https://devforums.apple.com/thread/142235?start=0&tstart=0

Comments

0

It is definitely a LLDB problem. I had the same, coud not debug at all. I switched back to GDB and it was ok

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.