My personal collection of useful Xcode code snippets.
- Add any code snippet file to Xcode user's code snippets directory. Create one if doesn't exist.
~/Library/Developer/Xcode/UserData/CodeSnippets
- Restart Xcode
- Enjoy!
Creates a template for CollectionView, shortcut: collection view adapter
// MARK: - UICollectionViewDataSource
extension <#AdapterName#>: UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
<#code#>
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
<#code#>
}
}
// MARK: - UICollectionViewDelegate
extension <#AdapterName#>: UICollectionViewDelegate {
}
// MARK: - UICollectionViewDelegateFlowLayout
extension <#AdapterName#>: UICollectionViewDelegateFlowLayout {
}
Add Mark Line, shortcut: mark
// MARK: - <#Name#>
Create an extension of ViewModel for analytics. It has enum Event
for various events, shortcut: viewmodel analytics
// MARK: - Analytics
extension <#ViewModelName#> {
enum Event {
}
func sendAnalyticsEvent(_ event: Event) {
}
}
Add comment describing hack code, shortcut: hack
// HACK:
Add Playground Page comment describing title, includes previous link, shortcut: title
/*:
[< Previous](@previous)
# - <#Title#>
*/
Add Playground Page comment showing next page link, includes summary, shortcut: summary
/*:
## Summary
1.
*/
//: [Next](@next)