Skip to content

Commit d2a74a9

Browse files
authored
Merge pull request #3 from hyperoslo/fix/swift3
Update snippets
2 parents bc20796 + 007fe8a commit d2a74a9

6 files changed

+58
-49
lines changed

README.md

+21-16
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,11 @@ var <#name#>: String? {
4747

4848
```swift
4949
if #available(iOS 9, *) {
50-
<#code#>
50+
<#API available statements#>
51+
} else if #available(macOS 10.12, *) {
52+
<#API available statements#>
5153
} else {
52-
<#code#>
54+
<#fallback statements#>
5355
}
5456
```
5557

@@ -128,51 +130,54 @@ subscript(<#name#>: <#type#>) -> <#type#> {
128130
}
129131
```
130132

131-
- swifttypealias
133+
- swiftguardself
132134

133135
```swift
134-
typealias <#alias#> = <#existingtype#>
136+
guard let `self` = self else {
137+
return
138+
}
135139
```
136140

137141
- swiftuitableviewdatasource
138142
```swift
139-
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
143+
func numberOfSections(in tableView: UITableView) -> Int {
140144
return <#count#>
141145
}
142146

143-
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
147+
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
144148
return <#count#>
145149
}
146150

147-
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
151+
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
148152
<#code#>
149153
}
150154
```
151155

152156
- swiftuicollectionviewdatasource
153157

154158
```swift
155-
func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
156-
<#count#>
159+
func numberOfSections(in collectionView: UICollectionView) -> Int {
160+
return <#count#>
157161
}
158162

159-
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
160-
<#count#>
163+
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
164+
return <#count#>
161165
}
162166

163-
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
167+
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
164168
<#code#>
165169
}
166170
```
167171

168172
- swiftuipickerviewdatasource
173+
169174
```swift
170-
func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int {
171-
<#count#>
175+
func numberOfComponents(in pickerView: UIPickerView) -> Int {
176+
return <#count#>
172177
}
173178

174-
func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
175-
<#count#>
179+
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
180+
return <#count#>
176181
}
177182
```
178183

Snippets/swiftcheckavailability.codesnippet

+6-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010
</array>
1111
<key>IDECodeSnippetContents</key>
1212
<string>if #available(iOS 9, *) {
13-
&lt;#code#&gt;
14-
} else {
15-
&lt;#code#&gt;
16-
}</string>
13+
&lt;#API available statements#&gt;
14+
} else if #available(macOS 10.12, *) {
15+
&lt;#API available statements#&gt;
16+
} else {
17+
&lt;#fallback statements#&gt;
18+
}</string>
1719
<key>IDECodeSnippetIdentifier</key>
1820
<string>286EE23E-804C-448C-84C2-437F71E31054</string>
1921
<key>IDECodeSnippetLanguage</key>

Snippets/swifttypealias.codesnippet renamed to Snippets/swiftguardself.codesnippet

+7-5
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,21 @@
33
<plist version="1.0">
44
<dict>
55
<key>IDECodeSnippetCompletionPrefix</key>
6-
<string>swifttypealias</string>
6+
<string>swiftguardself</string>
77
<key>IDECodeSnippetCompletionScopes</key>
88
<array>
9-
<string>ClassImplementation</string>
9+
<string>All</string>
1010
</array>
1111
<key>IDECodeSnippetContents</key>
12-
<string>typealias &lt;#alias#&gt; = &lt;#existingtype#&gt;</string>
12+
<string>guard let `self` = self else {
13+
return
14+
}</string>
1315
<key>IDECodeSnippetIdentifier</key>
14-
<string>5A840BC7-D419-4A82-A069-E9DDC4F8BA20</string>
16+
<string>FC0D62B1-F64B-47EB-A912-E0E6172B498A</string>
1517
<key>IDECodeSnippetLanguage</key>
1618
<string>Xcode.SourceCodeLanguage.Swift</string>
1719
<key>IDECodeSnippetTitle</key>
18-
<string>swifttypealias</string>
20+
<string>swiftguardself</string>
1921
<key>IDECodeSnippetUserSnippet</key>
2022
<true/>
2123
<key>IDECodeSnippetVersion</key>

Snippets/swiftuicollectionviewdatasource.codesnippet

+9-9
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@
99
<string>ClassImplementation</string>
1010
</array>
1111
<key>IDECodeSnippetContents</key>
12-
<string>func numberOfSectionsInCollectionView(collectionView: UICollectionView) -&gt; Int {
13-
&lt;#count#&gt;
14-
}
12+
<string>func numberOfSections(in collectionView: UICollectionView) -&gt; Int {
13+
return &lt;#count#&gt;
14+
}
1515

16-
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {
17-
&lt;#count#&gt;
18-
}
16+
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {
17+
return &lt;#count#&gt;
18+
}
1919

20-
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -&gt; UICollectionViewCell {
21-
&lt;#code#&gt;
22-
}</string>
20+
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell {
21+
&lt;#code#&gt;
22+
}</string>
2323
<key>IDECodeSnippetIdentifier</key>
2424
<string>F932ECD9-8F67-4C60-98CF-071204B1FF17</string>
2525
<key>IDECodeSnippetLanguage</key>

Snippets/swiftuipickerviewdatasource.codesnippet

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
<string>ClassImplementation</string>
1010
</array>
1111
<key>IDECodeSnippetContents</key>
12-
<string>func numberOfComponentsInPickerView(pickerView: UIPickerView) -&gt; Int {
13-
&lt;#count#&gt;
14-
}
12+
<string>func numberOfComponents(in pickerView: UIPickerView) -&gt; Int {
13+
return &lt;#count#&gt;
14+
}
1515

16-
func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -&gt; Int {
17-
&lt;#count#&gt;
18-
}</string>
16+
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -&gt; Int {
17+
return &lt;#count#&gt;
18+
}</string>
1919
<key>IDECodeSnippetIdentifier</key>
2020
<string>221CE04F-5B1F-4A86-8EB3-52FAEF45CF0A</string>
2121
<key>IDECodeSnippetLanguage</key>

Snippets/swiftuitableviewdatasource.codesnippet

+9-9
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@
99
<string>ClassImplementation</string>
1010
</array>
1111
<key>IDECodeSnippetContents</key>
12-
<string>func numberOfSectionsInTableView(tableView: UITableView) -&gt; Int {
13-
return &lt;#count#&gt;
14-
}
12+
<string>func numberOfSections(in tableView: UITableView) -&gt; Int {
13+
return &lt;#count#&gt;
14+
}
1515

16-
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
17-
return &lt;#count#&gt;
18-
}
16+
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
17+
return &lt;#count#&gt;
18+
}
1919

20-
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
21-
&lt;#code#&gt;
22-
}</string>
20+
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
21+
&lt;#code#&gt;
22+
}</string>
2323
<key>IDECodeSnippetIdentifier</key>
2424
<string>CE2F717F-36C5-4A9F-A8D4-D8870E5572EC</string>
2525
<key>IDECodeSnippetLanguage</key>

0 commit comments

Comments
 (0)