これは、Apple が推奨する形式に厳密に従っているわけではなく、あなたの質問に直接答えるものでもありませんが、通知やキー名を作成するときに少し入力する手間を省くために使用する便利なテキスト マクロを共有したいと思います。これらにキーボード ショートカットを割り当て、入力して[Did|Will] + [UniquePartOfName]
セグメントを選択し、ショートカットを押して変数とその値を生成できます。特定のクラスのヘッダーでこれらの文字列を定義している場合$(FILENAMEASIDENTIFIER)
の代わりに使用することもでき、それは提案に準拠します。$(PROJECTNAME)
//MARK: Notification strings
{ /*
* Use the selection to make the name and string for a Notification.
* The string has a prefix placeholder, defaulting to the project name.
*/
Identifier = objc.notestring;
BasedOn = objc;
IsMenuItem = YES;
Name = "Notification Name From Selection";
TextString = "<#$(PROJECTNAME)#><#!notename!#>Notification = @\"<#$(PROJECTNAME)#><#!notename!#>Notification\";";
CompletionPrefix = notestring;
},
{ /*
* Insert placeholders to make the name and string for a Notification.
* This is for use without a selection, and so "only" activates at the
* beginning of the line.
*/
Identifier = objc.notestring.bol;
BasedOn = objc.notestring;
IsMenuItem = YES;
Name = "Notification Name From Selection";
OnlyAtBOL = YES;
CompletionPrefix = notestring;
},
//MARK: Default Key strings
{ /*
* Convert the selection into a name and string for use in the User
* Defaults system. The string has a placeholder for a prefix, which
* defaults to the project name.
*/
Identifier = objc.defaultskeystring;
BasedOn = objc;
IsMenuItem = YES;
Name = "UserDefaults Key From Selection";
OnlyAtBOL = NO;
TextString = "<#$(PROJECTNAME)#><#!keyname!#>Key = @\"<#$(PROJECTNAME)#><#!keyname!#>Key\";";
CompletionPrefix = defaultskey;
},
{ /*
* Insert placeholders to make the name and string for a a key for the
* User Defaults system. This is for use without a selection, and so
* "only" activates at the beginning of the line.
*/
Identifier = objc.defaultskeystring.bol;
BasedOn = objc.defaultskeystring;
IsMenuItem = YES;
OnlyAtBOL = YES;
Name = "UserDefaults Key From Selection";
CompletionPrefix = defaultskey;
},
これらは Xcode 3 マクロです。Xcode 4 (まだ使用していません) ではマクロ システムが異なることは知っていますが、変換は簡単で自動化できると思います。