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 UIView { | |
func layout(using constraints: [NSLayoutConstraint]) { | |
translatesAutoresizingMaskIntoConstraints = false | |
NSLayoutConstraint.activate(constraints) | |
} | |
} | |
// Example | |
label.layout(using: [ |
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
func colorPair(light: UIColor, dark: UIColor) -> UIColor { | |
UIColor { traitCollection -> UIColor in | |
switch traitCollection.userInterfaceStyle { | |
case .dark: | |
return dark | |
case .light, .unspecified: | |
return light | |
} | |
} | |
} |
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
import Foundation | |
enum Configuration { | |
enum Error: Swift.Error { | |
case missingKey, invalidValue | |
} | |
static func value<T>(for key: String) throws -> T where T: LosslessStringConvertible { | |
guard let object = Bundle.main.object(forInfoDictionaryKey:key) else { | |
throw Error.missingKey |
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
import CoreData | |
import UIKit | |
// ./NoteList.xcdatamodeld | |
class CoreDataManager { | |
static let sharedInstance = CoreDataManager() | |
private init() { } |
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
// | |
// CollectionViewController.swift | |
// sampleApp | |
// | |
// Created by Erdem ILDIZ on 30.05.2020. | |
// Copyright © 2020 Erdem ILDIZ. All rights reserved. | |
// | |
import UIKit | |
import Combine |
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
xcodebuild archive -scheme SampleMyFramework -archivePath "./build/ios_sim.xcarchive" -sdk iphonesimulator SKIP_INSTALL=NO | |
xcodebuild archive -scheme SampleMyFramework -archivePath "./build/ios.xcarchive" -sdk iphoneos SKIP_INSTALL=NO | |
xcodebuild -create-xcframework -framework "./build/ios.xcarchive/Products/Library/Frameworks/SampleMyFramework.framework" -framework "./build/ios_sim.xcarchive/Products/Library/Frameworks/SampleMyFramework.framework" -output "./build/SampleMyFramework.xcframework" |
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
import Foundation | |
func entryTime(s: String, keypad: String) -> Int { | |
var time = 0 | |
var lastKeyPadIndex = -1 | |
s.forEach { charOfs in | |
if let currentIndex = keypad.firstIndex(of: charOfs)?.utf16Offset(in: keypad) { | |
var keyPadIndex = 1 | |
if (currentIndex > 2 && currentIndex < 6) { keyPadIndex = 2 } |
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
// Source: https://sarunw.com/posts/easy-way-to-detect-retain-cycle-in-view-controller/ | |
IMAGE URL: https://d33wubrfki0l68.cloudfront.net/ed072d774d90c6c39313c572521165b1cd23e5da/c5b38/images/debug-deinit-breakpoint-result.png |
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
import SwiftUI | |
import ClockKit | |
struct ProgressSample: View { | |
var body: some View { | |
ProgressView(value: 0.7) | |
.progressViewStyle(CircularProgressViewStyle()) | |
} | |
} |
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
import SwiftUI | |
import ClockKit | |
struct GaugeSample: View { | |
var body: some View { | |
Gauge(value: 5.8, in: 3...10) { | |
Image(systemName: "drop.fill") | |
.foregroundColor(.green) | |
} | |
.gaugeStyle(CircularGaugeStyle()) |