I have a class, Song, which subclasses NSManagedObject. I’m using GDB to try and figure out a problem I’m having, and am having a hard time calling an accessor on my class using gdb.
Song.h:
@property (nonatomic, retain) NSString * title;
Song.m:
@dynamic title;
In the debugger, I see the “title” field on the object, when I try to print the value using the accessor, which should be generated at runtime if I understand correctly, it 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.
Chances are I’m doing something really stupid here, but what am I doing wrong? Is there any way to introspect an object and see what messages it will respond to using GDB?
Sadly, this is how
gdbbehaves. Rather than asking the object whether it will respond to a selector, it seems to just look at the object’s implementation either now or at compile time (I haven’t worked out which yet). Because Core Data attributes are dealt with during the message forwarding process, the debugger doesn’t believe thatNSManagedObjectwill respond to the attribute selectors.This is probably worth reporting as a bug to Apple, so they can fix the debugger.