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 UIKit | |
print(UITraitCollection.current.displayScale) // 3.0 (if device is iPhone 14.0) | |
print(UIScreen.main.scale) // 3.0 (if device is iPhone 14.0) | |
var pixelLengthForUIKit: CGFloat = { | |
1 / UITraitCollection.current.displayScale | |
} |
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 ContentView: View { | |
var body: some View { | |
VStack { | |
globeLabel | |
.padding() | |
.mainCell() // Applying quite simple custom modifier | |
} | |
} |
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 ContentView: View { | |
var body: some View { | |
VStack { | |
globeLabel | |
.padding() | |
} | |
} |
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 csv | |
import requests | |
from bs4 import BeautifulSoup | |
def parse_collection_item(item): | |
h4 = item.find('h4') | |
event = item.find('li', class_='video-tag event').text | |
a = item.find('a', class_='video-image-link') | |
link_path = a.get('href') | |
url = 'https://developer.apple.com' + link_path |
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 UIKit | |
struct ImageCache { | |
static func loadImage(url: URL, user: User) async throws -> (UIImage, User) { | |
if let cachedImage = InMemoryImageCache.shared.get(forKey: url) { | |
return (cachedImage, user) | |
} | |
let urlRequest = URLRequest(url: url) | |
let (data, response) = try await URLSession.shared.data(for: urlRequest) |
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 UIKit | |
let stackView = UIStackView() | |
contentView.addSubview(stackView) | |
stackView.axis = .horizontal // axis's default value is horizontal. | |
// 以下2行はセット | |
stackView.isLayoutMarginsRelativeArrangement = true | |
stackView.directionalLayoutMargins = .init(top: 0, leading: 16, bottom: 0, trailing: 16) | |
stackView.spacing = 6 |
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
//: A UIKit based Playground for presenting user interface | |
import UIKit | |
import PlaygroundSupport | |
class MyViewController : UIViewController { | |
override func loadView() { | |
let view = UIView() | |
view.backgroundColor = .white |
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
@IBDesignable | |
public final class RoundedCornersLabel: UILabel { | |
public override init(frame: CGRect) { | |
super.init(frame: frame) | |
configure() | |
} | |
public required init?(coder: NSCoder) { | |
super.init(coder: coder) | |
configure() |
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
// for var i = 0; i < 5; i += 1 | |
for i in stride(from: 0, to: 5, by: 1) { | |
print(i) // 0, 1, 2, 3, 4 | |
} |
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 | |
@testable import Foobar | |
import Quick | |
import Nimble | |
import Mockingjay | |
import APIKit | |
final class FooRequestSpec: QuickSpec { | |
override func spec() { | |
describe("FooRequest") { |