Skip to content

Instantly share code, notes, and snippets.

@Sab-swiftlin
Sab-swiftlin / Sequence+.swift
Last active February 28, 2022 08:51
Map for Swift Concurrency
extension Sequence {
func asyncMap<T>(_ transform: (Element) async throws -> T) async rethrows -> [T] {
var values = [T]()
for element in self {
try await values.append(transform(element))
}
return values
}
func asyncParallelMap<T>(_ transform:@escaping (Element) async throws -> T) async rethrows -> [T] {
@Sab-swiftlin
Sab-swiftlin / BorderedLabel.swift
Last active May 16, 2020 12:45
Bordered label in Swift.
import UIKit
class BorderedLabel: UILabel {
@IBInspectable var strokeSize: CGFloat = 0
@IBInspectable var strokeColor: UIColor = .clear
@IBInspectable var leftPadding: CGFloat = 0
@IBInspectable var rightPadding: CGFloat = 0
@IBInspectable var topPadding: CGFloat = 0
@IBInspectable var bottomPadding: CGFloat = 0