Display subclass data in XCode Expression window

Posted by Nick VanderPyle on Stack Overflow See other posts from Stack Overflow or by Nick VanderPyle
Published on 2010-03-29T21:44:16Z Indexed on 2010/03/30 5:13 UTC
Read the original article Hit count: 317

Filed under:
|
|

I'm debugging an iPhone application I've written using XCode 3.2 and I cannot view the relevant public properties of an object I pull from Core Data. When I watch the object in the Expressions window it only displays the data from the base NSManagedObject. I'd like to see the properties that are on the subclass, not the superclass.

If it helps, here's some of the code I'm using.

Settings is a subclass of NSManagedObject. I created it using XCode's built-in modeler. Declared like:

@interface Settings :  NSManagedObject  
{
}

@property (nonatomic, retain) NSNumber * hasNews;
@property (nonatomic, retain) NSString * logoUrl;
@property (nonatomic, retain) NSNumber * hasPaymentGateway;
@property (nonatomic, retain) NSString * customerCode;
...

In the interface of my controller I have:

Settings *settings;

I populate settings with:

settings = (Settings *)[NSEntityDescription
    insertNewObjectForEntityForName:@"Settings"
    inManagedObjectContext:UIAppManagedObjectContext()];

I then set the properties like:

settings.hasNews = [NSNumber numberWithBool:TRUE];

I've tried casting settings as (Settings *) in the Expression window but that doesn't help. All I see are the properties to NSManagedObject. I'm using NSLog but would rather not.

© Stack Overflow or respective owner

Related posts about xcode

Related posts about objective-c