struct A {
bridge bridge_name {
func foo() {}
}
}
let a = A()
- A vector contains at least one type.
vector T
- is a list of typeT
of an arbitrary length, such as T1, T2, ...vector(n) T
- is a list with the length of maximal n T's, such as T1, T2, ... , Tn
// vectorized tuple with arbitrary length (like an existetial that can accept a tuple of type `T` of any length)
var t1: (vector Int) = (1, 2)
t1 = (1, 2, 3)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Currently it would look like this: | |
let myLongString = "Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.\n\nNam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.\n\nDuis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis." | |
// With the accepted version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIColor { | |
public var grayscale: UIColor { | |
var (red, green, blue, alpha) = (CGFloat(0), CGFloat(0), CGFloat(0), CGFloat(0)) | |
if self.getRed(&red, green: &green, blue: &blue, alpha: &alpha) { | |
// https://en.wikipedia.org/wiki/Grayscale | |
return UIColor(white: red * 0.299 + green * 0.587 + blue * 0.114, alpha: alpha) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum Foo : OptionSet { | |
case a | |
case b | |
case value(UInt8) | |
public var rawValue: UInt8 { | |
switch self { | |
case .a: |
In Swift 3 the string literal is a simple stream of characters that is enclosed by starting and ending "
delimiters without new lines after and before the delimiters.
// Example #1
"\"Title\"\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit. Integer elementum commodo sem, a congue orci porta sit amet.\nDuis facilisis, est et vehicula congue, turpis dui ultricies nunc, ut elementum quam elit nec felis."
This issue makes it very hard to write code that has a fixed line width.
print("\"text\" \"text\" \"text\" text text text text text text text text text\ntext text text text text text text")
Allow:
print("
\"text\" \"text\" \"text\" text text text text \
text text text text text\n
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ViewController.swift | |
// test | |
// | |
// Created by Andrew Carter on 6/7/17. | |
// Copyright © 2017 Andrew Carter. All rights reserved. | |
// | |
import UIKit |
A layout guide for iOS 10 that is very similar to the safeAreaLayoutGuide
from iOS 11.
extension UIView {
///
private final class LayoutGuide : UILayoutGuide {}
///
var guardedAreaLayoutGuide: UILayoutGuide {
if #available(iOS 11, *) {