This commit is contained in:
2024-04-30 07:08:23 +02:00
commit a711247971
2043 changed files with 16874 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: available
# key: available
# --
@available(iOS $1, *)

View 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

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: dispatchAfter
# key: dispatchAfter
# --
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds($1)) {
$0
}

View File

@@ -0,0 +1,10 @@
# -*- mode: snippet -*-
# name: dispatchAsync
# key: dispatchAsync
# --
DispatchQueue.global(qos: .default).async {
$1
DispatchQueue.main.async {
$0
}
}

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: dispatchMain
# key: dispatchMain
# --
DispatchQueue.main.async(execute: { () -> Void in
$0
})

View 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)
}

View 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
View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: fori
# key: fori
# --
for $1 in $2 {
$0
}

7
snippets/swift-mode/func Normal file
View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: func
# key: func
# --
func $1() -> $2 {
$0
}

7
snippets/swift-mode/if Normal file
View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: if (...) { ... }
# key: if
# --
if $1 {
$0
}

View 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
View File

@@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: let
# key: let
# --
let $1: $2 = $0

5
snippets/swift-mode/mark Normal file
View File

@@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: mark
# key: mark
# --
// MARK: - $1

8
snippets/swift-mode/prop Normal file
View File

@@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# name: prop-getset
# key: prop-getset
# --
var $1: $2 {
get {$3}
set {$3 = value }
}

View 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
}

View File

@@ -0,0 +1,11 @@
# -*- mode: snippet -*-
# name: trycatch
# key: trycatch
# --
do {
try $1
} catch $2 {
$3
} catch $4 {
$5
}

View 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)

View 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
}

View 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) {
}

View 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) {
}

View 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? {
}

View 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
View File

@@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: var
# key: var
# --
var $1: $2 = $0

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: while
# key: while
# --
while $1 {
$0
}