All Projects → ismetanin → Xcodecodesnippets

ismetanin / Xcodecodesnippets

Licence: mit
Code snippets for Xcode.

Programming Languages

shell
77523 projects
swift
15916 projects

Projects that are alternatives of or similar to Xcodecodesnippets

Xcactionbar
"Alfred for Xcode" plugin
Stars: ✭ 1,217 (+4407.41%)
Mutual labels:  xcode, snippets
Awesome Swiftui
A collaborative list of awesome articles, talks, books, videos and code examples about SwiftUI.
Stars: ✭ 878 (+3151.85%)
Mutual labels:  xcode
Fapanels
FAPanels - Swift
Stars: ✭ 850 (+3048.15%)
Mutual labels:  xcode
30 Seconds Of Java
Curated collection of useful little Java functions that you can understand quickly
Stars: ✭ 872 (+3129.63%)
Mutual labels:  snippets
U17
精仿有妖气漫画(Swift5)
Stars: ✭ 853 (+3059.26%)
Mutual labels:  xcode
Jazzy
Both Swift and Objective-C projects are supported.
Stars: ✭ 7,078 (+26114.81%)
Mutual labels:  xcode
Atom Modular Snippets
:atom: A modular solution to snippets in @Atom.
Stars: ✭ 8 (-70.37%)
Mutual labels:  snippets
Lab
Lab wraps Git or Hub, making it simple to clone, fork, and interact with repositories on GitLab
Stars: ✭ 911 (+3274.07%)
Mutual labels:  snippets
Xcode Starter Pack
My personal default xcconfig files and whatnot for a new project
Stars: ✭ 15 (-44.44%)
Mutual labels:  xcode
Swiftui Grid
🚀 SwiftUI Grid layout with custom styles
Stars: ✭ 872 (+3129.63%)
Mutual labels:  xcode
Drl Theme Manager
Xcode File Template to generate theme manager for Swift 3+
Stars: ✭ 12 (-55.56%)
Mutual labels:  xcode
Agalertviewwithprogressbar
Stars: ✭ 9 (-66.67%)
Mutual labels:  xcode
Xcbt
⌛️xcbt shows Xcode build time of a specified project.
Stars: ✭ 14 (-48.15%)
Mutual labels:  xcode
Gisto
Gisto is a Cross-platform snippets management desktop application that allows you and/or your team share code snippets fast and easily. Based on GitHub Gists Infrastructure which means you can use all your existing snippets by connecting your GitHub account! Gisto started as an attempt to fulfill the lack of a syntax highlighted and cloud synchronized code snippet solution. You may thing of Gisto as Evernote for code.
Stars: ✭ 853 (+3059.26%)
Mutual labels:  snippets
Refresher
DEPRECATED: Pull to refresh in Swift
Stars: ✭ 885 (+3177.78%)
Mutual labels:  xcode
Xcodeeditor
An API for manipulating Xcode project files.
Stars: ✭ 851 (+3051.85%)
Mutual labels:  xcode
Language Dot
Dot (Graphviz) package for Atom
Stars: ✭ 11 (-59.26%)
Mutual labels:  snippets
Streetmusicmap
StreetMusicMap is a collab line up of street music performers from all over the world.
Stars: ✭ 13 (-51.85%)
Mutual labels:  xcode
Quiver
Validation, searching and filtering made easy for swift.
Stars: ✭ 27 (+0%)
Mutual labels:  xcode
Gitversioningonxcode
Pretty Xcode Git versioning for iOS & macOS applications
Stars: ✭ 15 (-44.44%)
Mutual labels:  xcode

PRs Welcome

XcodeCodeSnippets

A set of snippets for Xcode.

Requirements

Xcode 7.3.1 or later.

Installation

To install or update the snippets you need:

  • Quit Xcode
  • On the command line:
cd ~/Downloads
git clone https://github.com/ismetanin/XcodeCodeSnippets
mkdir -p $HOME/Library/Developer/Xcode/UserData/CodeSnippets
cp XcodeCodeSnippets/CodeSnippets/* $HOME/Library/Developer/Xcode/UserData/CodeSnippets
rm -rf XcodeCodeSnippets

Or if you have a cloned repository:

  • On the command line, cd into the directory with snippets and write sh ./install.sh

List of snippets

MARKs

There are MARKs for Swift and Objective-C. For Swift there is prefix before each // MARK: - and for Objective-C prefix is #pragma mark -.

Shortcuts are equal to snippet body for example for // MARK: - Properties shortcut is Properties.

Available MARKs
Snippet
Just empty mark (// MARK: - or #pragma mark -)
Nested types
Constants
Subviews
NSLayoutConstraints
Properties
Public properties
Readonly properties
IBOutlets
Initialization and deinitialization
UITableViewCell
UIViewController
Actions
IBActions
Public methods
Internal methods
Private methods

Code

  • A template for creating TableViewAdapter, shortcut: Table View Adapter

    Code
     import UIKit
    
     protocol <#Your#>TableViewAdapterOutput {
     }
    
     final class <#Your#>TableViewAdapter: NSObject {
         // MARK: - Properties
    
         private let output: <#Your#>TableViewAdapterOutput
    
         private var items: [String]
         private var tableView: UITableView
    
         // MARK: - Initialization and deinitialization
    
         init(tableView: UITableView, output: <#Your#>TableViewAdapterOutput) {
             self.output = output
             self.tableView = tableView
             self.items = []
             super.init()
             setupTable()
         }
    
         // MARK: - Internal methods
    
         func configure(with items: [String]) {
             self.items = items
             tableView.reloadData()
         }
    
         // MARK: - Private methods
    
         private func setupTable() {
             tableView.delegate = self
             tableView.dataSource = self
             tableView.register(
                 UINib(nibName: String(describing: <#Your#>TableViewCell.self), bundle: nil),
                 forCellReuseIdentifier: String(describing: <#Your#>TableViewCell.self)
             )
         }
     }
    
     // MARK: - UITableViewDataSource
    
     extension <#Your#>TableViewAdapter: UITableViewDataSource {
         func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
             return items.count
         }
    
         func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
             let cell = tableView.dequeueReusableCell(
                 withIdentifier: String(describing: <#Your#>TableViewCell.self),
                 for: indexPath
             ) as? TableViewCell
             cell?.backgroundColor = .red
             return cell ?? <#Your#>UITableViewCell()
         }
     }
    
     // MARK: - UITableViewDelegate
    
     extension <#Your#>TableViewAdapter: UITableViewDelegate {
         func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
             tableView.deselectRow(at: indexPath, animated: true)
         }
     }
    
  • A code block for creating user property in UserDefaults extension, shortcut: Defaults Key

    Code
     var <#defaultsKey#>: <#Type#> {
         get { return <#typeof#>(forKey: #function) }
         set { set(newValue, forKey: #function) }
     }
    
  • A code block for layouting child view anchors equal to the parent view anchors, shortcut: Constraints - layout child as parent

    Code
     <#childView#>.translatesAutoresizingMaskIntoConstraints = false
    
     NSLayoutConstraint.activate([
         <#childView#>.topAnchor.constraint(equalTo: <#parentView#>.safeAreaLayoutGuide.topAnchor, constant: 0),
         <#childView#>.bottomAnchor.constraint(equalTo: <#parentView#>.safeAreaLayoutGuide.bottomAnchor, constant: 0),
         <#childView#>.leadingAnchor.constraint(equalTo: <#parentView#>.safeAreaLayoutGuide.leadingAnchor, constant: 0),
         <#childView#>.trailingAnchor.constraint(equalTo: <#parentView#>.safeAreaLayoutGuide.trailingAnchor, constant: 0)
         ])
    
  • A code block for user property creating in NSNotification.Name extension, shortcut: NSNotification Name

    Code
    static let <#notificationName#> = NSNotification.Name("<#projectName#>.notifications.<#notificationName#>")
    
  • A code block for creating template comments for unit test, shortcut: testtemplate

    Code
    // given
    
    // when
    
    // then
    
    
  • A code block for creating template constants enum, shortcut: Constants enum

    Code
     // MARK: - Nested types
    
     private enum Constants {
    
     }
    
  • A code block for creating keyboard notifications detector, shortcut: Keyboard detector

    Code
    func addKeyboardObservers() {
         NotificationCenter.default.addObserver(self,
                                                selector: #selector(keyboardWillShow),
                                                name: UIResponder.keyboardWillShowNotification,
                                                object: nil)
         NotificationCenter.default.addObserver(self,
                                                selector: #selector(keyboardWillHide),
                                                name: UIResponder.keyboardWillHideNotification,
                                                object: nil)
     }
    
     @objc
     func keyboardWillShow(notification: NSNotification) {
         guard
             let frame = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue
         else {
             return
         }
     }
    
     @objc
     func keyboardWillHide() {
    
     }
    

Author

Ivan Smetanin, [email protected]

License

XcodeCodeSnippets is available under the MIT license. See the LICENSE file for more info.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].