如何在Xcode中为我们的自定义方法和属性添加使用提示?

时间:2013-08-14 13:04:26

标签: ios objective-c xcode

Code completion with usage hints at the bottom

在附图中,Xcode显示了其类的使用提示(底部两行)。同样,是否可以为我的自定义类方法和属性提供自己的提示?

1 个答案:

答案 0 :(得分:11)

您可以通过在标题中的声明上方添加特定格式的注释来完成此操作。 e.x:

/**
 *  This is my awesome new property!!!
 */
@property (strong, nonatomic) NSObject *someProperty;


/**
 *  An even cooler description!
 *
 *  @param  string  some string
 *  @param  arr some array
 */
- (void)myAwesomeMethodWithAweomseParamOfType:(NSString *)string andOtherParam:(NSArray *)arr;

然后当我转到我的实现文件并开始输入...

enter image description here enter image description here

但是,如果您不想记住如何格式化这些注释的所有细节,请从github下载VVDocumneter。这是一个Xcode插件,会自动添加这些评论。您所要做的就是导航到声明上方的行,然后点击///