Xcode 3 中的 Xcode 4 NSLog 宏链接 [英] Xcode 4 NSLog Macro link in Xcode 3
问题描述
在 Xcode <版本 4,有一个宏可以快速编写 NSLog
语句.我可以打字(我认为,使用我的运动记忆):
In Xcode < version 4, there was a macro to quickly write NSLog
statements. I could type (I think, using my motor memory):
log control+.
代码完整/宏可以:
NSLog(|);
|
是光标.
在 Xcode 4 中是否有类似的东西可以实现这一点?
Is there anything similar to accomplish this in Xcode 4?
谢谢
罗斯
推荐答案
我也很想念这个宏.感谢 Kendall 的 示例,我能够重新创建它.
I really miss this macro too. Thanks to Kendall's example, I was able to recreate it.
如果不存在,请转到此文件夹或创建一个:
Go to this folder or create one if doesn't exist:
~/Library/Developer/XCode/UserData/CodeSnippets
然后创建一个名为 NSLog.codesnippet 的文件并粘贴以下内容:
Then create a file called NSLog.codesnippet and paste in the following:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDECodeSnippetCompletionPrefix</key>
<string>log</string>
<key>IDECodeSnippetCompletionScopes</key>
<array>
<string>All</string>
</array>
<key>IDECodeSnippetContents</key>
<string>NSLog(@"<#Comment#>");
</string>
<key>IDECodeSnippetIdentifier</key>
<string>nslog1</string>
<key>IDECodeSnippetLanguage</key>
<string>Xcode.SourceCodeLanguage.Objective-C</string>
<key>IDECodeSnippetTitle</key>
<string>NSLogComment</string>
<key>IDECodeSnippetUserSnippet</key>
<true/>
<key>IDECodeSnippetVersion</key>
<integer>2</integer>
</dict>
</plist>
重新启动 Xcode 并在项目中的文件中键入 l.如果没有显示自动完成,点击转义,然后选择日志 - NSLog 评论"选项,然后点击标签.
Restart Xcode and type l into a file in your project. If autocomplete isn't showing, hit escape and then choose the "log - NSLog comment" option and then hit tab.
使用过一次后,您可能只需要使用 l+tab 即可自动完成.
After you've used it once, you'll probably only need to use l+tab for the autocomplete.
您可以创建任意数量的.只需确保文件名、IDECodeSnippetIdentifier 和 IDECodeSnippetCompletionPrefix 都是唯一的.
You can create as many as you like. Just make sure the filename, the IDECodeSnippetIdentifier and the IDECodeSnippetCompletionPrefix are all unique.
GitHub 上提供了更多示例.
这篇关于Xcode 3 中的 Xcode 4 NSLog 宏链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!