{"id":3288,"url":"https://github.com/iwasrobbed/Swift-CheatSheet","last_synced_at":"2025-08-03T13:32:25.614Z","repository":{"id":23147214,"uuid":"26502516","full_name":"iwasrobbed/Swift-CheatSheet","owner":"iwasrobbed","description":"A quick reference cheat sheet for common, high level topics in Swift.","archived":false,"fork":false,"pushed_at":"2017-10-29T21:50:49.000Z","size":79,"stargazers_count":997,"open_issues_count":4,"forks_count":121,"subscribers_count":63,"default_branch":"master","last_synced_at":"2024-11-30T18:15:09.987Z","etag":null,"topics":["cheatsheet","cheatsheets","ios","swift","swift-programming-language"],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iwasrobbed.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-11-11T20:15:41.000Z","updated_at":"2024-11-20T23:54:42.000Z","dependencies_parsed_at":"2022-07-27T03:47:23.635Z","dependency_job_id":null,"html_url":"https://github.com/iwasrobbed/Swift-CheatSheet","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iwasrobbed%2FSwift-CheatSheet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iwasrobbed%2FSwift-CheatSheet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iwasrobbed%2FSwift-CheatSheet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iwasrobbed%2FSwift-CheatSheet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iwasrobbed","download_url":"https://codeload.github.com/iwasrobbed/Swift-CheatSheet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228548567,"owners_count":17935221,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cheatsheet","cheatsheets","ios","swift","swift-programming-language"],"created_at":"2024-01-05T20:16:37.164Z","updated_at":"2024-12-07T01:30:46.134Z","avatar_url":"https://github.com/iwasrobbed.png","language":null,"funding_links":[],"categories":["Programming Languages","WebSocket","Reference"],"sub_categories":["Other free courses","React-Like","Other Xcode"],"readme":"## Swift 3+ Cheat Sheet\n\nWant to help improve this? File an issue or open a pull request! :)\n\nThis is not meant to be a beginner's guide or a detailed discussion about Swift; it is meant to be a quick reference to common, high level topics.\n\n* Read the [Objective-C](https://github.com/iwasrobbed/Objective-C-CheatSheet) cheatsheet as well.\n\n**Note**: This was written this fairly quickly, mostly to teach myself Swift, so it still needs a lot of love and there are important sections still missing. Please feel free to edit this document to update or improve upon it, making sure to keep with the general formatting of the document.  The list of contributors can be [found here](https://github.com/iwasrobbed/Swift-CheatSheet/graphs/contributors).\n\nIf something isn't mentioned here, it's probably covered in detail in one of these:\n\n* [Apple: A Swift Tour](https://developer.apple.com/library/mac/documentation/Swift/Conceptual/Swift_Programming_Language/GuidedTour.html)\n* [Apple: Swift Programming Language](https://developer.apple.com/library/mac/documentation/Swift/Conceptual/Swift_Programming_Language/TheBasics.html#//apple_ref/doc/uid/TP40014097-CH5-XID_467)\n* [Apple iBooks: Swift Programming Language](https://itunes.apple.com/us/book/swift-programming-language/id881256329?mt=11)\n* [Apple: Using Swift with Objective-C and Cocoa](https://developer.apple.com/library/ios/documentation/swift/conceptual/buildingcocoaapps/index.html)\n* [objc.io](http://www.objc.io)\n* [NSHipster](http://nshipster.com)\n* [Functional Programming in Swift](http://www.objc.io/books/)\n\n### Table of Contents\n\n* [Commenting](#commenting)\n* [Data Types](#data-types)\n* [Operators](#operators)\n* [Operator Overloading](#operator-overloading)\n* [Declaring Classes](#declaring-classes)\n* [Declarations](#declarations)\n* [Literals](#literals)\n* [Functions](#functions)\n* [Constants and Variables](#constants-and-variables)\n* [Naming Conventions](#naming-conventions)\n* [Closures](#closures)\n* [Generics](#generics)\n* [Control Statements](#control-statements)\n* [Extending Classes](#extending-classes)\n* [Error Handling](#error-handling)\n* [Passing Information](#passing-information)\n* [User Defaults](#user-defaults)\n* [Common Patterns](#common-patterns)\n* [Unicode Support](#unicode-support)\n\n## Commenting\n\nComments should be used to organize code and to provide extra information for future refactoring or for other developers who might be reading your code.  Comments are ignored by the compiler so they do not increase the compiled program size.\n\nTwo ways of commenting:\n\n```swift\n// This is an inline comment\n\n/* This is a block comment\n   and it can span multiple lines. */\n\n// You can also use it to comment out code\n/*\nfunc doWork() {\n  // Implement this\n}\n*/\n```\n\n### MARK\n\nUsing `MARK` to organize your code:\n\n```swift\n// MARK: - Use mark to logically organize your code\n\n// Declare some functions or variables here\n\n// MARK: - They also show up nicely in the properties/functions list in Xcode\n\n// Declare some more functions or variables here\n```\n\n### FIXME\n\nUsing `FIXME` to remember to fix your code:\n\n```swift\n// Some broken code might be here\n\n// FIXME: Use fixme to create a reminder to fix broken code later\n```\n\n`FIXME` works a lot like `MARK` because it makes organizing code easier, but it's used exclusively when you need to remember to fix something.\n\n### TODO\n\nUsing `TODO` to remember to add, delete, or generally refactor your code:\n\n````swift\n// Some incomplete code might be here\n\n// TODO: Use todo to create a reminder to finish things up later\n````\n\n`TODO` is very similar to `FIXME` and `MARK`, but it's used exclusively when you need to remember to add, delete, or change your code later.\n\n**Auto-generating method documentation:**\nIn a method's preceding line, press `⌥ Option + ⌘ Command + /` to automatically generate a documentation stub for your method.\n\n[Back to top](#swift-3-cheat-sheet)\n\n## Data Types\n\n### Size\n\nPermissible sizes of data types are determined by how many bytes of memory are allocated for that specific type and whether it's a 32-bit or 64-bit environment.  In a 32-bit environment, `long` is given 4 bytes, which equates to a total range of `2^(4*8)` (with 8 bits in a byte) or `4294967295`.  In a 64-bit environment, `long` is given 8 bytes, which equates to `2^(8*8)` or `1.84467440737096e19`.\n\nFor a complete guide to 64-bit changes, please [see the transition document](https://developer.apple.com/library/mac/documentation/Darwin/Conceptual/64bitPorting/transition/transition.html#//apple_ref/doc/uid/TP40001064-CH207-TPXREF101).\n\n### C Primitives\n\nUnless you have a good reason to use C primitives, you should just use the Swift types to ensure compability going foward.\n\nIn fact, Swift just aliases C types to a Swift equivalent:\n\n```swift\n// C char is aliased as an Int8 and unsigned as UInt8\nlet aChar = CChar()\nlet anUnsignedChar = CUnsignedChar()\nprint(\"C char size: \\(MemoryLayout.size(ofValue: aChar)) with min: \\(Int8.min) and max: \\(Int8.max)\")\n// C char size: 1 with min: -128 and max: 127\nprint(\"C unsigned char size: \\(MemoryLayout.size(ofValue: anUnsignedChar)) with min: \\(UInt8.min) and max: \\(UInt8.max)\")\n// C unsigned char size: 1 with min: 0 and max: 255\n\n// C short is aliased as an Int16 and unsigned as UInt16\nlet aShort = CShort()\nlet unsignedShort = CUnsignedShort()\nprint(\"C short size: \\(MemoryLayout.size(ofValue: aShort)) with min: \\(Int16.min) and max: \\(Int16.max)\")\n// C short size: 2 with min: -32768 and max: 32767\nprint(\"C unsigned short size: \\(MemoryLayout.size(ofValue: unsignedShort)) with min: \\(UInt16.min) and max: \\(UInt16.max)\")\n// C unsigned short size: 2 with min: 0 and max: 65535\n\n// C int is aliased as an Int32 and unsigned as UInt32\nlet anInt = CInt()\nlet unsignedInt = CUnsignedInt()\nprint(\"C int size: \\(MemoryLayout.size(ofValue: anInt)) with min: \\(Int32.min) and max: \\(Int32.max)\")\n// C int size: 4 with min: -2147483648 and max: 2147483647\nprint(\"C unsigned int size: \\(MemoryLayout.size(ofValue: unsignedInt)) with min: \\(UInt32.min) and max: \\(UInt32.max)\")\n// C unsigned int size: 4 with min: 0 and max: 4294967295\n\n// C long is aliased as an Int and unsigned as UInt\nlet aLong = CLong()\nlet unsignedLong = CUnsignedLong()\nprint(\"C long size: \\(MemoryLayout.size(ofValue: aLong)) with min: \\(Int.min) and max: \\(Int.max)\")\n// C long size: 8 with min: -9223372036854775808 and max: 9223372036854775807\nprint(\"C unsigned long size: \\(MemoryLayout.size(ofValue: unsignedLong)) with min: \\(UInt.min) and max: \\(UInt.max)\")\n// C unsigned long size: 8 with min: 0 and max: 18446744073709551615\n\n// C long long is aliased as an Int64 and unsigned as UInt64\nlet aLongLong = CLongLong()\nlet unsignedLongLong = CUnsignedLongLong()\nprint(\"C long long size: \\(MemoryLayout.size(ofValue: aLongLong)) with min: \\(Int64.min) and max: \\(Int64.max)\")\n// C long long size: 8 with min: -9223372036854775808 and max: 9223372036854775807\nprint(\"C unsigned long long size: \\(MemoryLayout.size(ofValue: unsignedLongLong)) with min: \\(UInt64.min) and max: \\(UInt64.max)\")\n// C unsigned long long size: 8 with min: 0 and max: 18446744073709551615\n```\n\nFrom the [docs](https://developer.apple.com/library/ios/documentation/swift/conceptual/buildingcocoaapps/InteractingWithCAPIs.html):\n\nC Type | Swift Type\n:---: | :---:\n| bool | CBool\n| char, signed char | CChar\n| unsigned char | CUnsignedChar\n| short | CShort\n| unsigned short | CUnsignedShort\n| int | CInt\n| unsigned int | CUnsignedInt\n| long | CLong\n| unsigned long | CUnsignedLong\n| long long | CLongLong\n| unsigned long long | CUnsignedLongLong\n| wchar_t | CWideChar\n| char16_t | CChar16\n| char32_t | CChar32\n| float | CFloat\n| double | CDouble\n\n#### Integers\n\nIntegers can be signed or unsigned.  When signed, they can be either positive or negative and when unsigned, they can only be positive.\n\nApple states: _Unless you need to work with a specific size of integer, always use `Int` for integer values in your code. This aids code consistency and interoperability. Even on 32-bit platforms, `Int` [...] is large enough for many integer ranges._\n\n**Fixed width integer types with their accompanying byte sizes as the variable names:**\n\n```swift\n// Exact integer types\nlet aOneByteInt: Int8 = 127\nlet aOneByteUnsignedInt: UInt8 = 255\nlet aTwoByteInt: Int16 = 32767\nlet aTwoByteUnsignedInt: UInt16 = 65535\nlet aFourByteInt: Int32 = 2147483647\nlet aFourByteUnsignedInt: UInt32 = 4294967295\nlet anEightByteInt: Int64 = 9223372036854775807\nlet anEightByteUnsignedInt: UInt64 = 18446744073709551615\n\n// Minimum integer types\nlet aTinyInt: Int8 = 127\nlet aTinyUnsignedInt: UInt8 = 255\nlet aMediumInt: Int16 = 32767\nlet aMediumUnsignedInt: UInt16  = 65535\nlet aNormalInt: Int32  = 2147483647\nlet aNormalUnsignedInt: UInt32 = 4294967295\nlet aBigInt: Int64 = 9223372036854775807\nlet aBigUnsignedInt: UInt64 = 18446744073709551615\n\n// The largest supported integer type\nlet theBiggestInt: IntMax = 9223372036854775807\nlet theBiggestUnsignedInt: UIntMax = 18446744073709551615\n```\n\n#### Floating Point\n\nFloats cannot be signed or unsigned.\n\n```swift\n// Single precision (32-bit) floating-point. Use it when floating-point values do not require 64-bit precision.\nlet aFloat = Float()\nprint(\"Float size: \\(MemoryLayout.size(ofValue: aFloat))\")\n// Float size: 4\n\n// Double precision (64-bit) floating-point. Use it when floating-point values must be very large or particularly precise.\nlet aDouble = Double()\nprint(\"Double size: \\(MemoryLayout.size(ofValue: aDouble))\")\n// Double size: 8\n```\n\n#### Boolean\n\n```swift\n// Boolean\nlet isBool: Bool = true // Or false\n```\n\nIn Objective-C comparative statements, `0` and `nil` were considered `false` and any non-zero/non-nil values were considered `true`. However, this is not the case in Swift. Instead, you'll need to directly check their value such as `if x == 0` or `if object != nil`\n\n#### Primitives\n\n**nil** : Used to specify a null object pointer.  When classes are first initialized, all properties of the class point to `nil`.\n\n### Enum \u0026 Bitmask Types\n\nEnumeration types can be defined as follows:\n\n```swift\n// Specifying a typed enum with a name (recommended way)\nenum UITableViewCellStyle: Int {\n    case default, valueOne, valueTwo, subtitle\n}\n\n// Accessing it:\nlet cellStyle: UITableViewCellStyle = .default\n```\n\nAs of Swift 3, all enum options should be named in lowerCamelCased.\n\n#### Working with Bitmasks\n\nNewer Swift versions have a nice substitute for the old `NS_OPTIONS` macro for creating bitmasks to compare to.\n\nAn example for posterity:\n\n```swift\nstruct Options: OptionSet {\n    let rawValue: Int\n\n    init(rawValue: Int) {\n        self.rawValue = rawValue\n    }\n\n    init(number: Int) {\n        self.init(rawValue: 1 \u003c\u003c number)\n    }\n\n    static let OptionOne = Options(number: 0)\n    static let OptionTwo = Options(number: 1)\n    static let OptionThree = Options(number: 2)\n}\n\nlet options: Options = [.OptionOne, .OptionTwo]\n\noptions.contains(.OptionOne) // true\noptions.contains(.OptionThree) // false\n```\n\n### Type Casting\n\nSometimes it is necessary to cast an object into a specific class or data type.  Examples of this would be casting from a `Float` to an `Int` or from a `UITableViewCell` to a subclass such as `RPTableViewCell`.\n\n#### Checking Types\n\nSwift uses `is` and `as` both for checking object types as well as conformance to a given protocol.\n\n#### Operator: is\n\nChecking object type using `is`:\n\n```swift\nif item is Movie {\n    movieCount += 1\n    print(\"It is a movie.\")\n} else if item is Song {\n    songCount += 1\n    print(\"It is a song.\")\n}\n\n```\n\nThe `is` operator returns `true `if an instance is of that object type, or conforms to the specified protocol, and returns `false` if it does not.\n\n#### Operators: as? and as!\n\nIf you want to be able to easily access the data during one of these checks, you can use `as?` to optionally (or `as!` to force) unwrap the object when necessary:\n\n```swift\nfor item in library {\n    if let movie = item as? Movie {\n        print(\"Director: \\(movie.director)\")\n    } else if let song = item as? Song {\n        print(\"Artist: \\(song.artist)\")\n    }\n}\n```\n\nThe `as?` version of the downcast operator returns an optional value of the object or protocol's type, and this value is `nil` if the downcast fails or this instance does not conform to the specified protocol.\n\nThe `as!` version of the downcast operator forces the downcast to the specified object or protocol type and triggers a runtime error if the downcast does not succeed.\n\n#### Casting from Generic Types\n\nIf you're working with `AnyObject` objects given from the Cocoa API, you can use:\n\n```swift\nfor movie in someObjects as! [Movie] {\n    // do stuff\n}\n```\n\nIf given an array with `Any` objects, you can use a `switch` statement with the type defined for each `case`:\n\n```swift\nvar things = [Any]()\n\nfor thing in things {\n    switch thing {\n    case 0 as Int:\n        print(\"Zero as an Int\")\n    case let someString as! String:\n        print(\"S string value of \\\"\\(someString)\\\"\")\n    case let (x, y) as! (Double, Double):\n        print(\"An (x, y) point at \\(x), \\(y)\")\n    case let movie as! Movie:\n        print(\"A movie called '\\(movie.name)' by director \\(movie.director)\")\n    default:\n        print(\"Didn't match any of the cases specified\")\n    }\n}\n```\n\n#### Basic Casting\n\nSwift also offers some simple methods of casting between it's given data types.\n\n```swift\n// Example 1:\nlet aDifferentDataType: Float = 3.14\nlet anInt: Int = Int(aDifferentDataType)\n\n// Example 2:\nlet aString: String = String(anInt)\n```\n\n[Back to top](#swift-3-cheat-sheet)\n\n## Operators\n\nSwift supports most standard C operators and improves several capabilities to eliminate common coding errors. The assignment operator `=` does not return a value, to prevent it from being mistakenly used when the equal to operator `==` is intended.\n\nArithmetic operators (`+`, `-`, `*`, `/`, `%`) detect and disallow value overflow, to avoid unexpected results when working with numbers that become larger or smaller than the allowed value range of the type that stores them.\n\n#### Arithmetic Operators\n\nOperator | Purpose\n:---: | ---\n| + | Addition\n| - | Subtraction\n| * | Multiplication\n| / | Division\n| % | Remainder\n\n#### Comparative Operators\n\nOperator | Purpose\n:---: | ---\n| == | Equal to\n| === | Identical to\n| != | Not equal to\n| !== | Not identical to\n| ~= | Pattern match\n| \u003e | Greater than\n| \u003c | Less than\n| \u003e= | Greater than or equal to\n| \u003c= | Less than or equal to\n\n#### Assignment Operators\n\nOperator | Purpose\n:---: | ---\n| = | Assign\n| += | Addition\n| -= | Subtraction\n| *= | Multiplication\n| /= | Division\n| %= | Remainder\n| \u0026= | Bitwise AND\n| \u0026#124;= | Bitwise Inclusive OR\n| ^= | Exclusive OR\n| \u003c\u003c= | Shift Left\n| \u003e\u003e= | Shift Right\n\n#### Logical Operators\n\nOperator | Purpose\n:---: | ---\n| ! | NOT\n| \u0026\u0026 | Logical AND\n| \u0026#124;\u0026#124; | Logical OR\n\n#### Range Operators\n\nOperator | Purpose\n:---: | ---\n| ..\u003c | Half-open range\n| ... | Closed range\n\n#### Bitwise Operators\n\nOperator | Purpose\n:---: | ---\n| \u0026 | Bitwise AND\n| \u0026#124; | Bitwise Inclusive OR\n| ^ | Exclusive OR\n| ~ | Unary complement (bit inversion)\n| \u003c\u003c | Shift Left\n| \u003e\u003e | Shift Right\n\n#### Overflow and Underflow Operators\n\nTypically, assigning or incrementing an integer, float, or double past it's range would result in a runtime error. However, if you'd instead prefer to safely truncate the number of available bits, you can opt-in to have the variable overflow or underflow using the following operators:\n\nOperator | Purpose\n:---: | ---\n| \u0026+ | Addition\n| \u0026- | Subtraction\n| \u0026* | Multiplication\n\nExample for unsigned integers (works similarly for signed):\n\n```swift\nvar willOverflow = UInt8.max\n// willOverflow equals 255, which is the largest value a UInt8 can hold\nwillOverflow = willOverflow \u0026+ 1\n// willOverflow is now equal to 0\n\nvar willUnderflow = UInt8.min\n// willUnderflow equals 0, which is the smallest value a UInt8 can hold\nwillUnderflow = willUnderflow \u0026- 1\n// willUnderflow is now equal to 255\n```\n\n#### Other Operators\n\nOperator | Purpose\n:---: | ---\n| ?? | Nil coalescing\n| ?: | Ternary conditional\n| ! | Force unwrap object value\n| ? | Safely unwrap object value\n\n[Back to top](#swift-3-cheat-sheet)\n\n## Operator Overloading\n\nSwift allows you to overwrite existing operators or define new operators for existing or custom types. For example, this is why in Swift you can join strings using the `+` operator, even though it is typically used for math.\n\nOperator overloading is limited to the following symbols, `/ = - + * % \u003c \u003e ! \u0026 | ^ . ~`, however you cannot overload the `=` operator by itself (it must be combined with another symbol).\n\nOperators can be specified as:\n* `prefix`: goes before an object such as `-negativeNumber`\n* `infix`: goes between two objects, such as `a + b`\n* `postfix`: goes after an object, such as `unwrapMe!`\n\nExamples:\n\n```swift\nstruct Vector2D: CustomStringConvertible {\n    var x = 0.0, y = 0.0\n\n    var description: String {\n        return \"Vector2D(x: \\(x), y: \\(y))\"\n    }\n}\n\ninfix operator +-: AdditionPrecedence\nextension Vector2D {\n    static func +- (left: Vector2D, right: Vector2D) -\u003e Vector2D {\n        return Vector2D(x: left.x + right.x, y: left.y - right.y)\n    }\n}\nlet firstVector = Vector2D(x: 1.0, y: 2.0)\nlet secondVector = Vector2D(x: 3.0, y: 4.0)\nlet plusMinusVector = firstVector +- secondVector\n// plusMinusVector is a Vector2D instance with values of (4.0, -2.0)\n```\n\n[Back to top](#swift-3-cheat-sheet)\n\n## Declaring Classes\n\nClasses are typically declared using separate `.swift` files, but multiple classes can also be created within the same file if you'd like to organize it that way.\n\nUnlike Objective-C, there's no need for an interface file (`.h`) in Swift.\n\nThe implementation file should contain (in this order):\n* Any needed `import` statements\n* A `class` declaration which contains any constants or variables necessary for the class\n* All public and private functions\n\nExample:\n\nMyClass.swift\n\n```swift\nimport UIKit\n\nclass MyClass {\n    // Declare any constants or variables at the top\n    let kRPErrorDomain = \"com.myIncredibleApp.errors\"\n    var x: Int, y: Int\n\n    // Use mark statements to logically organize your code\n\n    // MARK: - Class Methods, e.g. MyClass.functionName()\n\n    class func alert() {\n        print(\"This is a class function.\")\n    }\n\n    // MARK: - Instance Methods, e.g. myClass.functionName()\n\n    init(x: Int, y: Int) {\n        self.x = x\n        self.y = y\n    }\n\n    // MARK: - Private Methods\n\n    private func pointLocation() -\u003e String {\n        return \"x: \\(x), y: \\(y)\"\n    }\n}\n```\n\n#### Instantiation\n\nWhen you want to create a new instance of a class, you use the syntax:\n\n```swift\nlet myClass = MyClass(x: 1, y: 2)\n```\n\nwhere `x` and `y` are variables that are passed in at the time of instantiation.\n\n[Back to top](#swift-3-cheat-sheet)\n\n## Declarations\n\nMore info [here in the docs](https://developer.apple.com/library/ios/documentation/swift/conceptual/Swift_Programming_Language/Declarations.html#//apple_ref/doc/uid/TP40014097-CH34-XID_704).\n\n#### Preprocessor\n\nSwift doesn't come with a preprocessor so it only supports a limited number of statements for build time. Things like `#define` have been replaced with global constants defined outside of a class.\n\nDirective | Purpose\n:---: | ---\n| #if | An `if` conditional statement\n| #elif | An `else if` conditional statement\n| #else | An `else` conditional statement\n| #endif | An `end if` conditional statement\n\n#### Imports\n\nDirective | Purpose\n:---: | ---\n| import | Imports a framework\n\n#### Constants \u0026 Variables\n\nDirective | Purpose\n:---: | ---\n| let | Declares local or global constant\n| var | Declares a local or global variable\n| class | Declares a class-level constant or variable\n| static | Declares a static type\n\n#### Classes, Structure, Functions and Protocols\n\nDirective | Purpose\n:---: | ---\n| typealias | Introduces a named alias of an existing type\n| enum | Introduces a named enumeration\n| struct | Introduces a named structure\n| class | Begins the declaration of a class\n| init | Introduces an initializer for a class, struct or enum\n| init? | Produces an optional instance or an implicitly unwrapped optional instance; can return `nil`\n| deinit | Declares a function called automatically when there are no longer any references to a class object, just before the class object is deallocated\n| func | Begins the declaration of a function\n| protocol | Begins the declaration of a formal protocol\n| static | Defines as type-level within struct or enum\n| convenience | Delegate the init process to another initializer or to one of the class’s designated initializers\n| extension | Extend the behavior of class, struct, or enum\n| subscript | Adds subscripting support for objects of a particular type, normally for providing a convenient syntax for accessing elements in a collective, list or sequence\n| override | Marks overriden initializers\n\n#### Operators\n\nDirective | Purpose\n:---: | ---\n| operator | Introduces a new infix, prefix, or postfix operator\n\n#### Declaration Modifiers\n\nDirective | Purpose\n:---: | ---\n| dynamic | Marks a member declaration so that access is always dynamically dispatched using the Objective-C runtime and never inlined or devirtualized by the compiler\n| final | Specifies that a class can’t be subclassed, or that a property, function, or subscript of a class can’t be overridden in any subclass\n| lazy | Indicates that the property’s initial value is calculated and stored at most once, when the property is first accessed\n| optional | Specifies that a protocol’s property, function, or subscript isn’t required to be implemented by conforming members\n| required | Marks the initializer so that every subclass must implement it\n| weak | Indicates that the variable or property has a weak reference to the object stored as its value\n\n#### Access Control\n\nDirective | Purpose\n:---: | ---\n| open | Can be subclassed outside of its own module and its methods overridden as well; truly open to modification by others and useful for framework builders\n| public | Can only be subclassed by its own module or have its methods overridden by others within the same module\n| internal | (Default) Indicates the entities are only available to the entire module that includes the definition, e.g. an app or framework target\n| fileprivate | Indicates the entities are available only from within the source file where they are defined\n| private | Indicates the entities are available only from within the declaring scope within the file where they are defined (e.g. within the `{ }` brackets only)\n\n[Back to top](#swift-3-cheat-sheet)\n\n## Literals\n\nLiterals are compiler directives which provide a shorthand notation for creating common objects.\n\nSyntax | What it does\n:---: | ---\n| `\"string\"` | Returns a `String` object\n| `28` | Returns an `Int`\n| `3.14`, `0xFp2`, `1.25e2` | Returns a `Double` object\n| `true`, `false` | Returns a `Bool` object\n| `[]` | Returns an `Array` object\n| `[keyName:value]` | Returns a `Dictionary` object\n| `0b` | Returns a binary digit\n| `0o` | Returns an octal digit\n| `0x` | Returns a hexadecimal digit\n\n#### Strings\n\nSpecial characters can be included:\n\n* Null Character: `\\0`\n* Backslash: `\\\\` (can be used to escape a double quote)\n* Horizontal Tab: `\\t`\n* Line Feed: `\\n`\n* Carriage Return: `\\r`\n* Double Quote: `\\\"`\n* Single Quote: `\\'`\n* Unicode scalar: `\\u{n}` where n is between one and eight hexadecimal digits\n\n#### Array Access Syntax\n\n```swift\nlet example = [ \"hi\", \"there\", 23, true ]\nprint(\"item at index 0: \\(example[0])\")\n```\n\n#### Dictionary Access Syntax\n\n```swift\nlet example = [ \"hi\" : \"there\", \"iOS\" : \"people\" ]\nif let value = example[\"hi\"] {\n    print(\"hi \\(value)\")\n}\n```\n\n#### Mutability\n\nFor mutable literals, declare it with `var`; immutable with `let`.\n\n[Back to top](#swift-3-cheat-sheet)\n\n## Functions\n\n#### Declaration Syntax\n\nFunctions without a return type use this format:\n\n```swift\n// Does not return anything or take any arguments\nfunc doWork() {\n    // Code\n}\n```\n\n`class` precedes declarations of class functions:\n\n```swift\n// Call on a class, e.g. MyClass.someClassFunction()\nclass func someClassFunction() {\n    // Code\n}\n```\n\n`static` is similar to class functions where you don't need an instance of the class or struct in order to call a method on it:\n\n```swift\n// Call on a class/struct, e.g. MyStruct.someStaticFunction()\nstatic func someStaticFunction() {\n    // Code\n}\n```\n\nDeclare instance functions:\n\n```swift\n// Called on an instance of a class, e.g. myClass.someInstanceFunction()\nfunc doMoreWork() {\n    // Code\n}\n```\n\nFunction arguments are declared within the parentheses:\n\n```swift\n// Draws a point\nfunc draw(point: CGPoint)\n```\n\nReturn types are declared as follows:\n\n```swift\n// Returns a String object for the given String argument\nfunc sayHelloToMyLilFriend(lilFriendsName: String) -\u003e String {\n    return \"Oh hello, \\(lilFriendsName). Cup of tea?\"\n}\n```\n\nYou can have multiple return values, referred to as a tuple:\n\n```swift\n// Returns multiple objects\nfunc sayHelloToMyLilFriend(lilFriendsName: String) -\u003e (msg: String, nameLength: Int) {\n    return (\"Oh hello, \\(lilFriendsName). Cup of tea?\", countElements(lilFriendsName))\n}\n\nvar hello = sayHelloToMyLilFriend(\"Rob\")\nprint(hello.msg) // \"Oh hello, Rob. Cup of tea?\"\nprint(hello.nameLength) // 3\n```\n\nAnd those multiple return values can be optional:\n\n```swift\nfunc sayHelloToMyLilFriend(lilFriendsName: String) -\u003e (msg: String, nameLength: Int)?\n```\n\nBy default, external parameter names are given when you call the function, but you can specify that one or more are not shown in the method signature by putting a `_` symbol in front of the parameter name:\n\n```swift\nfunc sayHelloToMyLilFriend(_ lilFriendsName: String) {\n    // Code\n}\n\nsayHelloToMyLilFriend(\"Rob\")\n```\n\nor you can rename the variable once within the method scope:\n\n```swift\nfunc sayHelloToMyLilFriend(friendsName lilFriendsName: String) {\n    // Code\n}\n\nsayHelloToMyLilFriend(friendsName: \"Rob\") // and local variable is `lilFriendsName`\n```\n\n\nYou can also specify default values for the parameters:\n\n```swift\nfunc sayHelloToMyLilFriend(_ lilFriendsName: String = \"Rob\") {\n    // Code\n}\n\nsayHelloToMyLilFriend() // \"Oh hello, Rob. Cup of tea?\"\nsayHelloToMyLilFriend(\"Jimbob\") // \"Oh hello, Jimbob. Cup of tea?\"\n```\n\nSwift also supports variadic parameters so you can have an open-ended number of parameters passed in:\n\n```swift\nfunc sayHelloToMyLilFriends(_ lilFriendsName: String...) {\n    // Code\n}\n\nsayHelloToMyLilFriends(\"Rob\", \"Jimbob\", \"Cletus\")\n// \"Oh hello, Rob, Jimbob and Cletus. Cup of tea?\"\n```\n\nAnd lastly, you can also use a prefix to declare input parameters as `inout`.\n\nAn in-out parameter has a value that is passed in to the function, is modified by the function, and is passed back out of the function to replace the original value.\n\nYou may remember `inout` parameters from Objective-C where you had to sometimes pass in an `\u0026error` parameter to certain methods, where the `\u0026` symbol specifies that you're actually passing in a pointer to the object instead of the object itself. The same applies to Swift's `inout` parameters now as well.\n\n#### Calling Functions\n\nFunctions are called using dot syntax: `myClass.doWork()` or `self.sayHelloToMyLilFriend(\"Rob Phillips\")`\n\n`self` is a reference to the function's containing class.\n\nAt times, it is necessary to call a function in the superclass using `super.someMethod()`.\n\n[Back to top](#swift-3-cheat-sheet)\n\n## Constants and Variables\n\nDeclaring a constant or variable allows you to maintain a reference to an object within a class or to pass objects between classes.\n\nConstants are defined with `let` and variables with `var`. By nature, constants are obviously immutable (i.e. cannot be changed once they are instantiated) and variables are mutable.\n\n```swift\nclass MyClass {\n\tlet text = \"Hello\" // Constant\n\tvar isComplete: Bool // Variable\n}\n```\n\nThere are many ways to declare properties in Swift, so here are a few examples:\n\n```swift\nvar myInt = 1 // inferred type\nvar myExplicitInt: Int = 1 // explicit type\nvar x = 1, y = 2, z = 3 // declare multiple variables\n\nlet (a,b) = (1,2) // declare multiple constants\n```\n\n#### Access Levels\n\nThe default access level for constants and variables is `internal`:\n\n```swift\nclass MyClass {\n    // Internal (default) properties\n\tvar text: String\n\tvar isComplete: Bool\n}\n```\n\nTo declare them publicly or openly, they should also be within a `public` or `open` class as shown below:\n\n```swift\npublic class MyClass {\n    // Public properties\n\tpublic var text: String\n\tpublic let x = 1\n}\n\n// Or\n\nopen class MyClass {\n    // Public properties\n\topen var text: String\n\topen let x = 1\n}\n```\n\nFile private variables and constants are declared with the `fileprivate` directive:\n\n```swift\nclass MyClass {\n    // Private properties\n\tfileprivate var text: String\n\tfileprivate let x = 1\n}\n```\n\n#### Getters and Setters\n\nIn Objective-C, variables were backed by getters, setters, and private instance variables created at build time. However, in Swift getters and setters are only used for computed properties and constants actually don't have a getter or setter at all.\n\nThe getter is used to read the value, and the setter is used to write the value. The setter clause is optional, and when only a getter is needed, you can omit both clauses and simply return the requested value directly. However, if you provide a setter clause, you must also provide a getter clause.\n\nYou can overrride the getter and setter of a property to create the illusion of the Objective-C property behavior, but you'd need to store them as a private property with a different name (not recommended for most scenarios):\n\n```swift\nprivate var _x: Int = 0\n\nvar x: Int {\n    get {\n        print(\"Accessing x...\")\n        return _x\n    }\n    set {\n        print(\"Setting x...\")\n        _x = newValue\n    }\n}\n```\n\n#### Access Callbacks\n\nSwift also has callbacks for when a property will be or was set using `willSet` and `didSet` shown below:\n\n```swift\nvar numberOfEdits = 0\nvar value: String = \"\" {\n    willSet {\n        print(\"About to set value...\")\n    }\n    didSet {\n        numberOfEdits += 1\n    }\n}\n```\n\n#### Accessing\n\nProperties can be accessed using dot notation:\n\n```swift\nmyClass.myVariableOrConstant\nself.myVariable // Self is optional here except within closure scopes\n```\n\n#### Local Variables\n\nLocal variables and constants only exist within the scope of a function.\n\n```swift\nfunc doWork() {\n    let localStringVariable = \"Some local string variable.\"\n    self.doSomething(string: localStringVariable)\n}\n```\n\n[Back to top](#swift-3-cheat-sheet)\n\n## Naming Conventions\n\nThe general rule of thumb: Clarity and brevity are both important, but clarity should never be sacrificed for brevity.\n\n#### Functions and Properties\n\nThese both use `camelCase` where the first letter of the first word is lowercase and the first letter of each additional word is capitalized.\n\n#### Class names and Protocols\n\nThese both use `CapitalCase` where the first letter of every word is capitalized.\n\n### Enums\n\nThe options in an enum should be `lowerCamelCased`\n\n#### Functions\n\nThese should use verbs if they perform some action (e.g. `performInBackground`).  You should be able to infer what is happening, what arguments a function takes, or what is being returned just by reading a function signature.\n\nExample:\n\n```swift\n// Correct\nfunc move(from start: Point, to end: Point) {}\n\n// Incorrect (likely too expressive, but arguable)\nfunc moveBetweenPoints(from start: Point, to end: Point) {}\n\n// Incorrect (not expressive enough and lacking argument clarity)\nfunc move(x: Point, y: Point) {}\n```\n\n[Back to top](#swift-3-cheat-sheet)\n\n## Closures\n\nClosures in Swift are similar to blocks in Objective-C and are essentially chunks of code, typically organized within a `{}` clause, that are passed between functions or to execute code as a callback within a function. Swift's `func` functions are actually just a special case of a closure in use.\n\n#### Syntax\n\n```swift\n{ (params) -\u003e returnType in\n    statements\n}\n```\n\n#### Examples\n\n```swift\n// Map just iterates over the array and performs whatever is in the closure on each item\nlet people = [\"Rob\", \"Jimbob\", \"Cletus\"]\npeople.map({\n    (person: String) -\u003e String in\n    \"Oh hai, \\(person)...\"\n})\n// Oh hai, Rob\n// Oh hai, Jimbob\n// Oh hai, Cletus\n\n// Closure for alphabetically reversing an array of names, where sorted is a Swift library function\nlet names = [\"Francesca\", \"Joe\", \"Bill\", \"Sally\", ]\nvar reversed = names.sorted { (s1: String, s2: String) -\u003e Bool in\n    return s1 \u003e s2\n}\n// Or on a single line:\nreversed = names.sorted{ (s1: String, s2: String) -\u003e Bool in return s1 \u003e s2 }\n// Or because Swift can infer the Bool type:\nreversed = names.sorted { s1, s2 in return s1 \u003e s2 }\n// Or because the return statement is implied:\nreversed = names.sorted { s1, s2 in s1 \u003e s2 }\n// Or even shorter using shorthand argument names, such as $0, $1, $2, etc.:\nreversed = names.sorted { $0 \u003e $1 }\n// Or just ridiculously short because Swift's String greater-than operator implementation exactly matches this function definition:\nreversed = names.sorted(by: \u003e)\n```\n\nIf the closure is the last parameter to the function, you can also use the trailing closure pattern. This is especially useful when the closure code is especially long and you'd like some extra space to organize it:\n\n```swift\nfunc someFunctionThatTakesAClosure(closure: () -\u003e ()) {\n    // function body goes here\n}\n\n// Instead of calling like this:\nsomeFunctionThatTakesAClosure({\n    // closure's body goes here\n})\n\n// You can use trailing closure like this:\nsomeFunctionThatTakesAClosure() {\n    // trailing closure's body goes here\n}\n```\n#### Capturing Values\n\nA closure can capture constants and variables from the surrounding context in which it is defined. The closure can then refer to and modify the values of those constants and variables from within its body, even if the original scope that defined the constants and variables no longer exists.\n\nIn Swift, the simplest form of a closure that can capture values is a nested function, written within the body of another function. A nested function can capture any of its outer function’s arguments and can also capture any constants and variables defined within the outer function.\n\n```swift\nfunc makeIncrementor(forIncrement amount: Int) -\u003e () -\u003e Int {\n    var runningTotal = 0\n    func incrementor() -\u003e Int {\n        runningTotal += amount\n        return runningTotal\n    }\n    return incrementor\n}\n```\n\nSwift determines what should be captured by reference and what should be copied by value. You don’t need to annotate a variable to say that they can be used within the nested function. Swift also handles all memory management involved in disposing of variables when they are no longer needed by the function.\n\n#### Capturing Self\n\nIf you create a closure that references `self.*` it will capture `self` and retain a strong reference to it. This is sometimes the intended behavior, but often could lead to retain cycles where both objects won't get deallocated at the end of their lifecycles.\n\nThe two best options are to use `unowned` or `weak`. This might look a bit messy, but saves a lot of headache.\n\nUse `unowned` when you know the closure will only be called if `self` still exists, but you don't want to create a strong (retain) reference.\n\nUse `weak` if there is a chance that `self` will not exist, or if the closure is not dependent upon `self` and will run without it. If you do use `weak` also remember that `self` will be an optional variable and should be checked for existence.\n\n```swift\ntypealias SomeClosureType = (_ value: String) -\u003e ()\n\nclass SomeClass {\n    fileprivate var currentValue = \"\"\n\n    init() {\n        someMethod { (value) in // Retained self\n            self.currentValue = value\n        }\n\n        someMethod { [unowned self] (value) in // Not retained, but expected to exist\n            self.currentValue = value\n\n        }\n\n        someMethod { [weak self] value in // Not retained, not expected to exist\n            // Or, alternatively you could do\n            guard let sSelf = self else { return }\n\n            // Or, alternatively use `self?` without the guard\n            sSelf.currentValue = value\n        }\n    }\n\n    func someMethod(closure: SomeClosureType) {\n        closure(\"Hai\")\n    }\n}\n```\n\nReference: [Apple: Automatic Reference Counting](https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/AutomaticReferenceCounting.html)\n\n[Back to top](#swift-3-cheat-sheet)\n\n## Generics\n\nComing soon...\n\n[Back to top](#swift-3-cheat-sheet)\n\n## Control Statements\n\nSwift uses all of the same control statements that other languages have:\n\n#### If-Else If-Else\n\n```swift\nif someTestCondition {\n    // Code to execute if the condition is true\n} else if someOtherTestCondition {\n    // Code to execute if the other test condition is true\n} else {\n    // Code to execute if the prior conditions are false\n}\n```\n\nAs you can see, parentheses are optional.\n\n#### Ternary Operators\n\nThe shorthand notation for an `if-else` statement is a ternary operator of the form: `someTestCondition ? doIfTrue : doIfFalse`\n\nExample:\n\n```swift\nfunc stringForTrueOrFalse(trueOrFalse: Bool) -\u003e String {\n    return trueOrFalse ? \"True\" : \"False\"\n}\n```\n\n#### Nil Coalescing Operators\n\nIn Swift, we need to consider the use of `optional` values. One very basic way to handle `nil` cases is with an `if-else` statement:\n\n```swift\nfunc stringForOptionalExistence(optionalValue: String?) -\u003e String {\n  if optionalValue != nil {\n    return optionalValue\n  } else {\n    return \"Empty\"\n  }\n}\n```\n\nIn this particular case, we are returning `optionalValue` if it is not `nil`, and `\"Empty\"` if `optionalValue` is `nil`. The shorthand notation for this type of `if(!=nil)-else` statement is a nil coalescing operator of the form: `optionalValue ?? nonOptionalValue`\n\nExample:\n\n```swift\nfunc stringForOptionalExistence(optionalValue: String?) -\u003e String {\n  return optionalValue ?? \"Empty\"\n}\n```\n\n#### For Loops\n\nSwift enables you to use ranges inside of `for` loops now:\n\n```swift\nfor index in 1...5 {\n    print(\"\\(index) times 5 is \\(index * 5)\")\n}\n\n// Or if you don't need the value of the index\nlet base = 3, power = 10\nvar answer = 1\nfor _ in 1...power {\n    answer *= base\n}\nprint(\"\\(base) to the power of \\(power) is \\(answer)\")\n// prints \"3 to the power of 10 is 59049\"\n```\n\n\n#### Enumerating arrays \u0026 dictionaries\n\n```swift\n// We explicitly cast to the Movie class from AnyObject class\nfor movie in someObjects as [Movie] {\n    // Code to execute each time\n}\n\n// Enumerating simple array\nlet names = [\"Anna\", \"Alex\", \"Brian\", \"Jack\"]\nfor name in names {\n    print(\"Hello, \\(name)!\")\n}\n\n// Enumerating simple dictionary\nlet numberOfLegs = [\"spider\": 8, \"ant\": 6, \"cat\": 4]\nfor (animalName, legCount) in numberOfLegs {\n    print(\"\\(animalName)s have \\(legCount) legs\")\n}\n```\n\nIf you need to cast to a certain object type, see the earlier discussion about the `as!` and `as?` keywords.\n\n#### While Loop\n\n```swift\nwhile someTestCondition {\n   // Code to execute while the condition is true\n}\n```\n\n#### Repeat While Loop\n\n```swift\nrepeat {\n    // Code to execute while the condition is true\n} while someTestCondition\n```\n\n#### Switch\n\nSwitch statements are often used in place of `if` statements if there is a need to test if a certain variable matches the value of another constant or variable.  For example, you may want to test if an error code integer you received matches an existing constant value or if it's a new error code.\n\n```swift\nswitch errorStatusCode {\n    case .network:\n        // Code to execute if it matches\n\n     case .wifi:\n        // Code to execute if it matches\n\n     default:\n        // Code to execute if nothing else matched\n}\n```\n\nSwitch statements in Swift do not fall through the bottom of each case and into the next one by default. Instead, the entire switch statement finishes its execution as soon as the first matching switch case is completed, without requiring an explicit `break` statement. This makes the switch statement safer and easier to use than in C, and avoids executing more than one switch case by mistake.\n\n#### Exiting Loops\n\nAlthough `break` is not required in Swift, you can still use a `break` statement to match and ignore a particular case, or to break out of a matched case before that case has completed its execution.\n\n* `return` : Stops execution and returns to the calling function.  It can also be used to return a value from a function.\n* `break` : Used to stop execution of a loop.\n\n[Back to top](#swift-3-cheat-sheet)\n\n## Extending Classes\n\nComing soon...\n\n[Back to top](#swift-3-cheat-sheet)\n\n## Error Handling\n\nComing soon...\n\n[Back to top](#swift-3-cheat-sheet)\n\n## Passing Information\n\nComing soon...\n\n[Back to top](#swift-3-cheat-sheet)\n\n## User Defaults\n\nUser defaults are basically a way of storing simple preference values which can be saved and restored across app launches.  It is not meant to be used as a data storage layer, like Core Data or sqlite.\n\n### Storing Values\n\n```swift\nlet userDefaults = UserDefaults.standard\nuserDefaults.setValue(\"Some Value\", forKey: \"RPSomeUserPreference\")\n```\n\n### Retrieving Values\n\n```swift\nlet userDefaults = UserDefaults.standard\nlet someValue = userDefaults.value(forKey: \"RPSomeUserPreference\") as AnyObject?\n```\n\nThere are also other convenience functions on `UserDefaults` instances such as `bool(forKey:...)`, `string(forKey:...)`, etc.\n\n[Back to top](#swift-3-cheat-sheet)\n\n## Common Patterns\n\nFor a comprehensive list of design patterns, as established by the Gang of Four, look here: [Design Patterns in Swift](https://github.com/ochococo/Design-Patterns-In-Swift)\n\n### Singletons\n\nSingleton's are a special kind of class where only one instance of the class exists for the current process. They are a convenient way to share data between different parts of an app without creating global variables or having to pass the data around manually, but they should be used sparingly since they often create tighter coupling between classes.\n\nTo turn a class into a singleton, you use the following implementation where the function name is prefixed with `shared` plus another word which best describes your class.  For example, if the class is a network or location manager, you would name the function `sharedManager` instead of `sharedInstance`.\n\n```swift\nclass MyClass {\n\n    // MARK: - Instantiation\n\n    // Naming convention:\n    // sharedInstance, sharedManager, sharedController, etc.\n    // depending on the class type\n    static let sharedInstance = MyClass()\n\n    // This prevents others from using the default '()' initializer for this class.\n    fileprivate init() {}\n\n    var isReady = true\n\n    // More class code here\n}\n```\n\n**Explanation**: The static constant `sharedInstance` is run as `dispatch_once` the first time that variable is accessed to make sure the initialization is atomic. This ensures it is thread safe, fast, lazy, and also bridged to ObjC for free. More from [here](http://krakendev.io/blog/the-right-way-to-write-a-singleton).\n\n**Usage**: You would get a reference to that singleton class in another class with the following code:\n\n```swift\n// Now you could do\nlet myClass = MyClass.sharedInstance\nlet answer = myClass.isReady ? \"Yep!\" : \"Nope!\"\nprint(\"Are you ready to rock and roll? \\(answer)\")\n```\n\n[Back to top](#swift-3-cheat-sheet)\n\n## Unicode Support\n\nAlthough I don't recommend this, Swift will compile even if you use emoji's in your code since it offers Unicode support.\n\nMore info from Apple [here](https://developer.apple.com/library/ios/documentation/swift/conceptual/Swift_Programming_Language/StringsAndCharacters.html)\n\n[Back to top](#swift-3-cheat-sheet)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiwasrobbed%2FSwift-CheatSheet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiwasrobbed%2FSwift-CheatSheet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiwasrobbed%2FSwift-CheatSheet/lists"}