yasi
yasi

Reputation: 483

How can I get @-directive-preprocessed Objective-C code

How can I see a preprocessed Objective-C code in which the Objective-C directives like @property and @synthesize are preprocessed?

I've searched this topic in Stackoverflow, there's some tips for how to see preprocessed code, for example Xcode Preprocessor Output. However, the "preprocessed code" does not involve preprocessed Objective-C directives. For example, in the "preprocessed code", the Objective-C directives like @property or @synthesize are not preprocessed.

Take the following code as an example,

    // ========= Person.h =========
@interface Person: NSObject
{
}
-(void) Print;
@property int age;
@end

// ========= Person.m =========
@implementation Person
-(void) Print
{
    NSLog(@"Print_Age:%d", _age);
}
@end

What I expect to see is something like this:

// ========= Person.h =========
@interface Person: NSObject
{
    int _age;
}
-(void) Print;
-(int) age;
-(void) setAge:(int) age;
@end

// ========= Person.m =========
@implementation Person
-(void) Print
{
    NSLog(@"Print_Age:%d", _age);
}
-(int) age {
    return _age;
}
-(void) setAge:(int) age {
    _age = age;
}
@end

How can I see it?

Upvotes: 0

Views: 33

Answers (1)

CRD
CRD

Reputation: 53010

Your last sentence contains the answer:

@property or @synthesize are not preprocessed

These are part of the language, they have nothing to do with the preprocessor. You can no more see these constructs after preprocessing than you can a while loop.

If you wish to see what they are compiled to you can examine the assembler, Xcode menu item Product > Perform Action > Assemble.

HTH

Upvotes: 1

Related Questions