Gdb: call access methods in a subclass of NSManagedObject?

I have a Song class that is subclassed by NSManagedObject. I use GDB to try to figure out what I have and it is difficult for me to name an accessory in my class using gdb.

Song.h:

@property (nonatomic, retain) NSString * title; 

Song.m:

 @dynamic title; 

In the debugger, I see the "name" field of the object, when I try to print the value using an accessor, which should be generated at run time, if I understand correctly, this gives me an error:

  (gdb) po aSong <Song: 0x59188d0> (entity: Song; id: 0x59162d0 <x-coredata://99BE63F8-840A-47B5-A259-BCD74E1811C4/Song/p2> ; data: { composers = "<relationship fault: 0x4d62f30 'composers'>"; dateCreated = nil; songLists = "<relationship fault: 0x59243c0 'songLists'>"; title = "cancel?"; }) (gdb) p aSong.title There is no member named title. (gdb) p [aSong title] Target does not respond to this message selector. 

Most likely I'm doing something really stupid here, but what am I doing wrong? Is there a way to introspect an object and see what messages it will respond to using GDB?

+8
ios objective-c gdb
source share
2 answers

Unfortunately, this is how gdb behaves. Instead of asking the object whether it would respond to the selector, it seems to just consider implementing the object either now or at compile time (I haven't developed it yet). Because Core Data attributes are processed during the message forwarding process, the debugger does not consider NSManagedObject to respond to the attribute selectors.

It is probably worth reporting a bug to Apple, so they can fix the debugger.

+3
source share

You can access dynamically generated properties in gdb using the valueForKey: method, as in [aSong valueForKey:@"title"] . (This method also works for synthesized properties if you are a masochist, but it actually comes in handy when checking NSManagedObject and its subclasses.)

+26
source share

All Articles