init
This commit is contained in:
5
snippets/swift-mode/available
Normal file
5
snippets/swift-mode/available
Normal file
@@ -0,0 +1,5 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: available
|
||||
# key: available
|
||||
# --
|
||||
@available(iOS $1, *)
|
||||
11
snippets/swift-mode/checkversion
Normal file
11
snippets/swift-mode/checkversion
Normal file
@@ -0,0 +1,11 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: checkversion
|
||||
# key: checkversion
|
||||
# --
|
||||
#if swift(>=3.0)
|
||||
$0
|
||||
#elseif swift(>=2.2)
|
||||
$2
|
||||
#elseif swift(>=2.1)
|
||||
$2
|
||||
#endif
|
||||
7
snippets/swift-mode/dispatchafter
Normal file
7
snippets/swift-mode/dispatchafter
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: dispatchAfter
|
||||
# key: dispatchAfter
|
||||
# --
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds($1)) {
|
||||
$0
|
||||
}
|
||||
10
snippets/swift-mode/dispatchasync
Normal file
10
snippets/swift-mode/dispatchasync
Normal file
@@ -0,0 +1,10 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: dispatchAsync
|
||||
# key: dispatchAsync
|
||||
# --
|
||||
DispatchQueue.global(qos: .default).async {
|
||||
$1
|
||||
DispatchQueue.main.async {
|
||||
$0
|
||||
}
|
||||
}
|
||||
7
snippets/swift-mode/dispatchmain
Normal file
7
snippets/swift-mode/dispatchmain
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: dispatchMain
|
||||
# key: dispatchMain
|
||||
# --
|
||||
DispatchQueue.main.async(execute: { () -> Void in
|
||||
$0
|
||||
})
|
||||
10
snippets/swift-mode/documentdirectory
Normal file
10
snippets/swift-mode/documentdirectory
Normal file
@@ -0,0 +1,10 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: documentDirectory
|
||||
# key: documentDirectory
|
||||
# --
|
||||
if let path =
|
||||
NSSearchPathForDirectoriesInDomains(
|
||||
FileManager.SearchPathDirectory.documentDirectory,
|
||||
FileManager.SearchPathDomainMask.userDomainMask, true).first {
|
||||
let documentsDirectoryURL = NSURL.fileURL(withPath: path)
|
||||
}
|
||||
7
snippets/swift-mode/forcase
Normal file
7
snippets/swift-mode/forcase
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: forcase
|
||||
# key: forcase
|
||||
# --
|
||||
for case let $1 in $2 as $3 {
|
||||
$0
|
||||
}
|
||||
7
snippets/swift-mode/fori
Normal file
7
snippets/swift-mode/fori
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: fori
|
||||
# key: fori
|
||||
# --
|
||||
for $1 in $2 {
|
||||
$0
|
||||
}
|
||||
7
snippets/swift-mode/func
Normal file
7
snippets/swift-mode/func
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: func
|
||||
# key: func
|
||||
# --
|
||||
func $1() -> $2 {
|
||||
$0
|
||||
}
|
||||
7
snippets/swift-mode/if
Normal file
7
snippets/swift-mode/if
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: if (...) { ... }
|
||||
# key: if
|
||||
# --
|
||||
if $1 {
|
||||
$0
|
||||
}
|
||||
7
snippets/swift-mode/initcoder
Normal file
7
snippets/swift-mode/initcoder
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: initcoder
|
||||
# key: initcoder
|
||||
# --
|
||||
public required init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
5
snippets/swift-mode/let
Normal file
5
snippets/swift-mode/let
Normal file
@@ -0,0 +1,5 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: let
|
||||
# key: let
|
||||
# --
|
||||
let $1: $2 = $0
|
||||
5
snippets/swift-mode/mark
Normal file
5
snippets/swift-mode/mark
Normal file
@@ -0,0 +1,5 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: mark
|
||||
# key: mark
|
||||
# --
|
||||
// MARK: - $1
|
||||
8
snippets/swift-mode/prop
Normal file
8
snippets/swift-mode/prop
Normal file
@@ -0,0 +1,8 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: prop-getset
|
||||
# key: prop-getset
|
||||
# --
|
||||
var $1: $2 {
|
||||
get {$3}
|
||||
set {$3 = value }
|
||||
}
|
||||
11
snippets/swift-mode/sortarrayofstrings
Normal file
11
snippets/swift-mode/sortarrayofstrings
Normal file
@@ -0,0 +1,11 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: sortarrayofstrings
|
||||
# key: sortarrayofstrings
|
||||
# --
|
||||
$1.sorted { (a, b) -> Bool in
|
||||
let comparisonResult = a.compare(b,
|
||||
options: [],
|
||||
range: a.range(of: a),
|
||||
locale: Locale.current)
|
||||
return comparisonResult == .orderedSame
|
||||
}
|
||||
11
snippets/swift-mode/trycatch
Normal file
11
snippets/swift-mode/trycatch
Normal file
@@ -0,0 +1,11 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: trycatch
|
||||
# key: trycatch
|
||||
# --
|
||||
do {
|
||||
try $1
|
||||
} catch $2 {
|
||||
$3
|
||||
} catch $4 {
|
||||
$5
|
||||
}
|
||||
17
snippets/swift-mode/uialertcontroller
Normal file
17
snippets/swift-mode/uialertcontroller
Normal file
@@ -0,0 +1,17 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: uialertController
|
||||
# key: uialertController
|
||||
# --
|
||||
let alert =
|
||||
UIAlertController(title: $1,
|
||||
message: $2,
|
||||
preferredStyle: .alert)
|
||||
alert.addAction(UIAlertAction(title: "",
|
||||
style: .default,
|
||||
handler: { (action) in
|
||||
alert.dismiss(animated: true, completion: {
|
||||
$0
|
||||
})
|
||||
}))
|
||||
|
||||
self.presentViewController(alert, animated: true, completion: nil)
|
||||
37
snippets/swift-mode/uicollectionviewdatasource
Normal file
37
snippets/swift-mode/uicollectionviewdatasource
Normal file
@@ -0,0 +1,37 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: uicollectionViewDataSource
|
||||
# key: uicollectionViewDataSource
|
||||
# --
|
||||
// MARK: UICollectionViewDataSource
|
||||
|
||||
func numberOfSections(in collectionView: UICollectionView) -> Int {
|
||||
return $1
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView,
|
||||
numberOfItemsInSection section: Int) -> Int {
|
||||
// TODO:- Required Method
|
||||
return $2
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView,
|
||||
cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
||||
let cell =
|
||||
collectionView.dequeueReusableCell(withReuseIdentifier: $3, for: indexPath)
|
||||
configureCell(cell: cell, forItemAt: indexPath)
|
||||
// TODO:- Required Method
|
||||
return cell
|
||||
}
|
||||
|
||||
func configureCell(cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
|
||||
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView,
|
||||
viewForSupplementaryElementOfKind kind: String,
|
||||
at indexPath: IndexPath) -> UICollectionReusableView {
|
||||
let view = collectionView.dequeueReusableSupplementaryView(
|
||||
ofKind: UICollectionElementKindSectionHeader,
|
||||
withReuseIdentifier: $3, for: indexPath) as UIView
|
||||
return view
|
||||
}
|
||||
15
snippets/swift-mode/uicollectionviewdelegate
Normal file
15
snippets/swift-mode/uicollectionviewdelegate
Normal file
@@ -0,0 +1,15 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: uiCollectionViewDelegate
|
||||
# key: uiCollectionViewDelegate
|
||||
# --
|
||||
// MARK: UICollectionViewDelegate
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView,
|
||||
didSelectItemAt indexPath: IndexPath) {
|
||||
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView,
|
||||
didDeselectItemAt indexPath: IndexPath) {
|
||||
|
||||
}
|
||||
26
snippets/swift-mode/uitableviewdatasource
Normal file
26
snippets/swift-mode/uitableviewdatasource
Normal file
@@ -0,0 +1,26 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: uitableViewDataSource
|
||||
# key: uitableViewDataSource
|
||||
# --
|
||||
// MARK: UITableViewDataSource
|
||||
|
||||
func numberOfSections(in tableView: UITableView) -> Int {
|
||||
return $1
|
||||
}
|
||||
|
||||
func tableView(_ tableView: UITableView,
|
||||
numberOfRowsInSection section: Int) -> Int {
|
||||
return $2
|
||||
}
|
||||
|
||||
func tableView(_ tableView: UITableView,
|
||||
cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||
let cell = tableView.dequeueReusableCell(withIdentifier: $3,
|
||||
for: indexPath)
|
||||
configureCell(cell: cell, forRowAt: indexPath)
|
||||
return cell
|
||||
}
|
||||
|
||||
func configureCell(cell: UITableViewCell, forRowAt indexPath: IndexPath) {
|
||||
|
||||
}
|
||||
34
snippets/swift-mode/uitableviewdelegate
Normal file
34
snippets/swift-mode/uitableviewdelegate
Normal file
@@ -0,0 +1,34 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: uiTableViewDelegate
|
||||
# key: uitableViewDelegate
|
||||
# --
|
||||
// MARK: UITableViewDelegate
|
||||
|
||||
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||
|
||||
}
|
||||
|
||||
func tableView(_ tableView: UITableView,
|
||||
heightForRowAt indexPath: IndexPath) -> CGFloat {
|
||||
|
||||
}
|
||||
|
||||
func tableView(_ tableView: UITableView,
|
||||
heightForHeaderInSection section: Int) -> CGFloat {
|
||||
|
||||
}
|
||||
|
||||
func tableView(_ tableView: UITableView,
|
||||
heightForFooterInSection section: Int) -> CGFloat {
|
||||
|
||||
}
|
||||
|
||||
func tableView(_ tableView: UITableView,
|
||||
viewForHeaderInSection section: Int) -> UIView? {
|
||||
|
||||
}
|
||||
|
||||
func tableView(_ tableView: UITableView,
|
||||
viewForFooterInSection section: Int) -> UIView? {
|
||||
|
||||
}
|
||||
25
snippets/swift-mode/uiviewcontrollerlifecycle
Normal file
25
snippets/swift-mode/uiviewcontrollerlifecycle
Normal file
@@ -0,0 +1,25 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: uiViewControllerLifecycle
|
||||
# key: uiViewControllerLifecycle
|
||||
# --
|
||||
// MARK: UIViewController lifecycle
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
}
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
}
|
||||
|
||||
override func viewDidAppear(_ animated: Bool) {
|
||||
super.viewDidAppear(animated)
|
||||
}
|
||||
|
||||
override func viewWillDisappear(_ animated: Bool) {
|
||||
super.viewWillDisappear(animated)
|
||||
}
|
||||
|
||||
override func viewDidDisappear(_ animated: Bool) {
|
||||
super.viewDidDisappear(animated)
|
||||
}
|
||||
5
snippets/swift-mode/var
Normal file
5
snippets/swift-mode/var
Normal file
@@ -0,0 +1,5 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: var
|
||||
# key: var
|
||||
# --
|
||||
var $1: $2 = $0
|
||||
7
snippets/swift-mode/while
Normal file
7
snippets/swift-mode/while
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: while
|
||||
# key: while
|
||||
# --
|
||||
while $1 {
|
||||
$0
|
||||
}
|
||||
Reference in New Issue
Block a user