This file contains hidden or 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
var people: [[String:Any]] = [ | |
[ | |
"firstName": "Calvin", | |
"lastName": "Newton", | |
"score": 13 | |
], | |
[ | |
"firstName": "Garry", | |
"lastName": "Mckenzie", | |
"score": 23 |
This file contains hidden or 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
struct Person { | |
let firstName: String | |
let lastName: String | |
let score: Int | |
} | |
var people: [Person] = [ | |
Person( | |
firstName: "Calvin", | |
lastName: "Newton", |
This file contains hidden or 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
#!/usr/bin/env xcrun swift | |
import WebKit | |
let application = NSApplication.sharedApplication() | |
application.setActivationPolicy(.Regular) | |
let window = NSWindow(contentRect: NSMakeRect(0, 0, 800, 600), | |
styleMask: NSTitledWindowMask | | |
NSClosableWindowMask | |
This file contains hidden or 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
Dear Steve, | |
It's a impossible task for Apple and the likes to maintain a | |
store of device decryption keys.Where should these keys be stored? | |
China will not trust the US to hand over the keys. So China | |
will demand Apple to store the keys within its border. | |
According to the language of "manufactured… and sold", then | |
this means China can demand Apple to store all the keys | |
inside China and be readily available to the government | |
without any warrant as netizens of China have no privacy rights. |
This file contains hidden or 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
import Foundation | |
struct Person: Codable { | |
let name: String | |
} | |
let person = Person(name: "Paul") | |
if #available(macOS 10.12, *) { |
This file contains hidden or 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
import QuartzCore | |
// make an Int array of random elements | |
let array = Array((1...2000).map { _ in Int(arc4random_uniform(2000)) } ) | |
let loopCount = 100_000 | |
// closure in a variable | |
let compareGreater: (Int, Int) -> Bool = { $0 > $1 } |
This file contains hidden or 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
import SwiftUI | |
struct AnimatedSlashSpeakerDemo: View { | |
// 0 mute is off, 1 mute is on | |
@State private var muteState: CGFloat = 0 | |
private static let imageDimension: CGFloat = 250 | |
var body: some View { | |
ZStack { | |
LinearGradient(gradient: Gradient(colors: [.pink, .orange, .blue, .red, .green, .purple, .yellow]), startPoint: .topLeading, endPoint: .bottomTrailing) |
This file contains hidden or 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
import SwiftUI | |
// pre-create one instance of MeasurementFormatter for our format needs | |
// re-use as needed | |
extension MeasurementFormatter { | |
static private let formatter: MeasurementFormatter = { | |
let formatter = MeasurementFormatter() | |
let numberFormatter = NumberFormatter() | |
numberFormatter.numberStyle = .decimal | |
numberFormatter.minimumFractionDigits = 2 |
This file contains hidden or 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
// | |
// VolumeSlider.swift | |
// TristateToggleProject | |
// | |
// Created by Matthew Young on 12/3/19. | |
// Copyright © 2019 Matthew Young. All rights reserved. | |
// | |
// https://stackoverflow.com/questions/58286350/how-to-create-custom-slider-by-using-swiftui |
This file contains hidden or 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
// WARNING: this only works in Xcode 11.4 beta 2 | |
// .minimumScaleFactor() is broken before and after | |
import SwiftUI | |
struct BigText: View { | |
private static let fontSize: CGFloat = 120 | |
@State private var margin: CGFloat = 0 | |
OlderNewer