3

I'm using @dynamic properties in combination with -forwardInvocation: to generate properties at runtime (like described in this answer). Now, when I try to work with such a property (assuming name is such a dynamic property) in GDB I always get this:

(gdb) call (void) [myObject setName:@"foo"]
Target does not respond to this message selector.

(gdb) po [myObject name]
Target does not respond to this message selector.

Is there a switch in GDB to make this work?

Community
  • 1
  • 1
Ortwin Gentz
  • 52,648
  • 24
  • 135
  • 213
  • How are you using forwardInvocation: in this scenario, in relation to your actual property getters and setters? – Ryan Feb 24 '11 at 20:56
  • @Ryan, exactly like in the linked answer, I'm using a dictionary as the data store as well. – Ortwin Gentz Feb 24 '11 at 21:20
  • It's possible that gdb is not prepared for this situation in its command-line interface implementation. Have you also implemented -methodSignatureForSelector: on your object? Also, taking a step back, I would expect you to get this message from gdb if your myObject variable was not pointing to a valid instance of your class. Does gdb print the class name you expect when you run this command: "po [myObject class]"? – Ryan Feb 24 '11 at 21:32
  • @Ryan, Yes, I implemented `-methodSignatureForSelector` and `po [myObject class]` prints the right class name. I should mention that the actual object I'm using in gdb is an instance of a subclass of the class with the @dynamic property. – Ortwin Gentz Feb 24 '11 at 22:31
  • Have you implemented -respondsToSelector: in the class? Perhaps gdb checks that and returns the error without trying. You could also just try adding the method calls in the program somewhere and see if they work, since the runtime will use the message forwarding. – ughoavgfhw Feb 24 '11 at 22:46
  • @ughoavgfhw good idea. I've added `-(BOOL)respondsToSelector:(SEL)aSelector {return YES;}`. Unfortunately it doesn't fix the problem. – Ortwin Gentz Feb 24 '11 at 22:54

1 Answers1

8

You can use po [myObject performSelector:@selector(name)] as a workaround, though it's quite awkward.

adurdin
  • 1,376
  • 1
  • 10
  • 15