Last active
October 26, 2018 09:54
-
-
Save natanrolnik/02107031f819a8c87011a51cb3d93dd7 to your computer and use it in GitHub Desktop.
Guard weak self Code Snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
Related: https://twitter.com/natanrolnik/status/1055756310023716865 | |
The following snippet should be copied to: | |
~/Library/Developer/Xcode/UserData/CodeSnippets | |
as, for example, guardweak.codesnippet. | |
When you type `guardweakself` inside a function scope, it will generate the following code snippet: | |
guard let <#self#> = <#self#> else { | |
return | |
} | |
--> | |
<?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>guardweakself</string> | |
<key>IDECodeSnippetCompletionScopes</key> | |
<array> | |
<string>CodeBlock</string> | |
</array> | |
<key>IDECodeSnippetContents</key> | |
<string>guard let <#self#> = <#self#> else { | |
return | |
}</string> | |
<key>IDECodeSnippetIdentifier</key> | |
<string>9C84BC04-E5B9-4BE6-911C-A0E2F0D2097A</string> | |
<key>IDECodeSnippetLanguage</key> | |
<string>Xcode.SourceCodeLanguage.Swift</string> | |
<key>IDECodeSnippetSummary</key> | |
<string>Guard a type exists when referencing it weakly</string> | |
<key>IDECodeSnippetTitle</key> | |
<string>Guard Weak Self</string> | |
<key>IDECodeSnippetUserSnippet</key> | |
<true/> | |
<key>IDECodeSnippetVersion</key> | |
<integer>0</integer> | |
</dict> | |
</plist> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment