在Xcode代码段中多次替换参数 [英] Replace parameter multiple times in Xcode code snippets
问题描述
我可以创建一个自定义代码段,该代码段使用在代码中多次替换的参数吗?
Can I create a custom snippet that takes a parameter that is replaced multiple times inside the code?
我尝试过类似的操作:
<#class#> instanceOf<#class#>;
但它不能同时替换两个类
插入代码片段并覆盖第一个参数时,将使用占位符。
but it doesn't replace both class
placeholders when I insert the snippet and write over the first parameter.
推荐答案
当时在Xcode 4.x中这是不可能的(2011年9月)。
This is not possible in Xcode 4.x at the time of writing (Sept. 2011).
如果您希望此功能恢复到Xcode 4.x中,请转到 bugreport.apple.com ,并报告我刚刚报告过的该rdar的副本:
If you want this feature back in Xcode 4.x, please go to bugreport.apple.com and report a duplicate for this rdar that I just preported:
摘要:具有相同名称的令牌的Xcode 4代码段应在填充其中一个令牌时同步
。
Summary: Xcode 4 snippets with tokens of same name should sync while filling one of them.
复制步骤:
1.定义以下代码段: extern NSString * const<#constant#> ;;
NSString * const<#constant#> = @<#constant#>;
- 将其拖放到您的代码中。
- 单击选项卡以选择令牌
<#constant#>
的实例。 - 键入 NSMySuperCoolConstantString 。
- Drop it into your code.
- Hit tab to select instance of token
<#constant#>
. - Type "NSMySuperCoolConstantString".
预期结果:
5。 NSString * const<#constant#> = @<#constant#>;
应该变成
NSString * const NSMySuperCoolConstantString =
就像在v3.x中一样。
@ NSMySuperCoolConstantString;
Expected Results:
5. NSString * const <#constant#> = @"<#constant#>";
should turn into
NSString * const NSMySuperCoolConstantString =
@"NSMySuperCoolConstantString";
as it used to do in v3.x.
实际结果:
5。 NSString * const<#constant#> = @<#constant#>;
保持
不变/不同步。
Actual Results:
5. NSString * const <#constant#> = @"<#constant#>";
stays
unchanged/unsynced.
回归:> strong>
注意:
此处是用于复制的 rdar参考:
rdar:// 10071607
OpenRadar 上的副本:
http:// openradar。 appspot.com/radar?id=1327411
And here a copy on OpenRadar:
http://openradar.appspot.com/radar?id=1327411
在以下位置:也可以随意将此rdar伪装:
While you're at it: Feel free to dupe this rdar as well:
Xcode 4:代码段功能回归
rdar :// 9192757
http://openradar.appspot.com/9192757
"Xcode 4: snippet functionality regressions"
rdar://9192757
http://openradar.appspot.com/9192757
这篇关于在Xcode代码段中多次替换参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!