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?
You can access dynamically generated properties in gdb
using the valueForKey:
method, as in [aSong valueForKey:@"title"]
. (This technique works for synthesized properties too, if you're a masochist, but really it only comes in handy when inspecting NSManagedObject
and its subclasses.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With