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 Book: Codable { | |
let title: String | |
let author: String | |
} | |
let KeyForUserDefaults = "myKey" | |
func save(_ books: [Book]) { |
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
private extension MyTests { | |
private func setLocaleAsJP() { | |
let original = class_getClassMethod(NSLocale.self, #selector(getter: NSLocale.current))! | |
let swizzled = class_getClassMethod(NSLocale.self, #selector(NSLocale.myCurrentLocale))! | |
method_exchangeImplementations(original, swizzled) | |
} | |
} | |
// https://stackoverflow.com/questions/31065859/how-can-i-change-the-locale-on-the-xcode-playground | |
fileprivate extension NSLocale { |
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
class Solution: | |
def twoSum(self, nums, target): | |
""" | |
:type nums: List[int] | |
:type target: int | |
:rtype: List[int] | |
""" | |
for i, num in enumerate(nums): | |
for j, num2 in enumerate(nums): | |
if i == j: |
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
print("start") | |
# update version numbers | |
current_ver_str = '1.0.0' # 現在のバージョン番号 | |
new_ver_str = '1.1.0' # 新しいバージョン番号 | |
# plist file names | |
file_names = [ | |
'Foo/SupportingFiles/Info.plist', | |
'Foo/SupportingFiles/InfoStaging.plist', |
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
// XCTestCase+Stub.swift | |
import Foundation | |
import XCTest | |
import Mockingjay | |
extension XCTestCase { | |
/// Web API のリクエストをテストプロジェクトの json でスタブする | |
/// | |
/// - Parameters: |
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") { |
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
@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
//: 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
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 |