https://github.com/artemnovichkov/xcode-snippets
My Xcode snippets
https://github.com/artemnovichkov/xcode-snippets
codesnippets swift xcode xcode-snippets
Last synced: 8 months ago
JSON representation
My Xcode snippets
- Host: GitHub
- URL: https://github.com/artemnovichkov/xcode-snippets
- Owner: artemnovichkov
- License: mit
- Created: 2017-11-22T10:55:05.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-01T04:55:23.000Z (about 8 years ago)
- Last Synced: 2025-07-18T14:00:30.402Z (8 months ago)
- Topics: codesnippets, swift, xcode, xcode-snippets
- Language: Shell
- Homepage:
- Size: 82 KB
- Stars: 7
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Usage
- Associated Object Declaration (`associated_object`)
```swift
private struct AssociatedKeys {
static var <#name#> = "<#name#>"
}
var <#name#>: String? {
get {
return objc_getAssociatedObject(self, &AssociatedKeys.<#name#>) as? String
}
set {
if let newValue = newValue {
objc_setAssociatedObject(self, &AssociatedKeys.<#name#>, newValue as String?, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
}
}
}
```
- Delay for calling (`async_after`)
```swift
DispatchQueue.main.asyncAfter(deadline: .now() + <#when: dispatch_time_t#>) {
}
```
- Guard Self Declaration (`guard_self`)
```swift
guard let `self` = self else {
return
}
```
- Lazy Button Declaration (`lazy_button`)
```swift
private(set) lazy var button: UIButton = {
let button = UIButton()
button.setTitle("", for: .normal)
button.setTitleColor(.black, for: .normal)
button.addTarget(self, action: #selector(), for: .touchUpInside)
return button
}()
```
- Lazy Label Declaration (`lazy_ll`)
```swift
private(set) lazy var titleLabel: UILabel = {
let label = UILabel()
label.font = .systemFont(ofSize: 17, weight: .regular)
label.textColor = .black
return label
}()
```
- Lazy Table View Declaration (`lazy_table`)
```swift
private(set) lazy var tableView: UITableView = {
let tableView = UITableView()
tableView.tableFooterView = UIView()
return tableView
}()
```
- Lazy [TableViewManager](https://github.com/rosberry/TableViewTools) Declaration (`lazy_tvm`)
```swift
fileprivate lazy var tableViewManager: TableViewManager = {
return TableViewManager(tableView: self.tableView)
}()
```
- Mark snippet (`mark`)
```swift
// MARK: - <#Title#>
```
- Protocol Function Declaration (`funcp`)
```swift
func <#name#>(<#parameters#>)
```
- Swift Singleton Declaration (`shared`)
```swift
static let shared = <# class #>
private init() {}
```
- View Did Appear Declaration (`viewDidAppear`)
```swift
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
}
```
## Installation
### Manual
Drag `.codesnippet` files into `~/Library/Developer/Xcode/UserData/CodeSnippets`.
### Automatic
Run the command in your terminal:
```bash
curl -fsSL https://raw.githubusercontent.com/artemnovichkov/xcode-snippets/master/install.sh | sh
```
## Author
Artem Novichkov, novichkoff93@gmail.com
## License
Xcode Snippets is available under the MIT license. See the LICENSE file for more info.