【问题标题】:How can I get @-directive-preprocessed Objective-C code如何获得 @-directive-preprocessed Objective-C 代码
【发布时间】:2015-07-06 09:00:36
【问题描述】:

如何查看预处理的 Objective-C 代码,其中 @property 和 @synthesize 等 Objective-C 指令已被预处理?

我在 Stackoverflow 中搜索过这个主题,有一些关于如何查看预处理代码的提示,例如 Xcode Preprocessor Output。但是,“预处理代码”不涉及预处理的 Objective-C 指令。例如,在“预处理代码”中,像 @property 或 @synthesize 这样的 Objective-C 指令没有被预处理。

以下面的代码为例,

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

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

我希望看到的是这样的:

// ========= 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

我怎样才能看到它?

【问题讨论】:

  • 我不明白你的问题是什么......

标签: objective-c


【解决方案1】:

你的最后一句话包含了答案:

@property 或 @synthesize 未经预处理

这些是语言的一部分,它们与预处理器无关。预处理后你看不到这些构造,就像while 循环一样。

如果您想查看它们编译成的内容,可以检查汇编程序,Xcode 菜单项Product > Perform Action > Assemble

HTH

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-09-20
    • 1970-01-01
    • 2012-10-06
    • 2012-09-30
    • 2011-09-07
    • 1970-01-01
    • 2011-05-07
    相关资源
    最近更新 更多