Skip to content

Instantly share code, notes, and snippets.

View erolando's full-sized avatar
🤠

Rolando Avila erolando

🤠
View GitHub Profile
@hectorddmx
hectorddmx / 2025-03-ios-interview-prep.md
Last active April 16, 2025 18:29
Document to help you prepare for iOS interviews

Questions about this format, send me a message: https://www.linkedin.com/in/hectorddmx

For technical interviews, let's ask candidates to refresh the following:

Q&A on iOS or mobile topics

Tasks:

  • reply brief answers on iOS topics to share your understanding
@simonbs
simonbs / SwiftUIHostingConfiguration.md
Last active March 9, 2025 17:09
In iOS 16, Apple added UIHostingConfiguration, making it straightforward to use a SwiftUI view in instances of UICollectionViewCell and UITableViewCell. This project shows how UIHostingConfiguration can be backported to iOS 14 by implementing a type that conforms to the UIContentConfiguration protocol.

SwiftUIHostingConfiguration

In iOS 16, Apple added UIHostingConfiguration, making it straightforward to use a SwiftUI view in instances of UICollectionViewCell and UITableViewCell. This gist shows how UIHostingConfiguration can be backported to iOS 14 by implementing a type that conforms to UIContentConfiguration.

Starting from iOS 16, we can use SwiftUI views in an instance of UICollectionView or UITableViewCell like this:

cell.contentConfiguration = UIHostingConfiguration {
    ExampleCellContentView(color: Color(item.color), text: item.text)
}
@karigrooms
karigrooms / swiftui-uihostingcontroller-example.swift
Created February 17, 2021 20:50
SwiftUI UIHostingController example for Lessons in SwiftUI blog post
import SwiftUI
import UIKit
class MyViewController: UIViewController {
// this is how you embed a SwiftUI View
lazy var host: UIViewController = {
return UIHostingController(rootView: MySwiftUIView())
}()
@rintoandrews90
rintoandrews90 / xcframework_generate.md
Created December 25, 2020 07:05 — forked from lalkrishna/xcframework_generate.md
Create xcframework instead of Universal(fat) frameworks.

Advantages of xcframework

  • Support for multiple platforms in the same framework.
  • Support for Swift, Objective-C and C.
  • Support for dynamic frameworks and static libraries.
  • Support for Swift Package Manager.
  • End of fat binaries.

Steps to create Aggregate target:

  1. Open Current framework project
@mrackwitz
mrackwitz / AutoHeightLabelView.swift
Created October 27, 2020 19:53
A UILabel-based SwiftUI view which auto-expands to the width of the container, and only expand to render the full height of the label.
struct AutoHeightLabelView: View {
var attributedString: NSAttributedString
var body: some View {
HorizontalGeometryReader { width in
UILabelView(
attributedString: attributedString,
preferredMaxLayoutWidth: width
)
}
@MarioIannotta
MarioIannotta / Decodable+CustomDateFormat.swift
Last active February 3, 2021 06:07
A little extension to easily decode date with custom formats
import Foundation
var json = """
{
"lastSyncDate": "2018-10-28T09:03:59+0000",
"posts": [
{
"id": 0,
"title": "Swift 4 Codable: tips and tricks",
"link": "https://medium.com/@MarioIannotta/swift-4-codable-tips-and-tricks-7ab4674736d2",
import Foundation
public struct Log
{
public static var isEnabled = true
public static func debug(_ m: @autoclosure ()->String, _ file: Any? = #file, _ f: String = #function, _ line: UInt = #line) {
print(m(), file ?? "", f, line)
}
@gonzalezreal
gonzalezreal / KeyedDecodingContainer+EmptyRepresentable.swift
Last active January 11, 2023 08:25
A technique to avoid having optional array properties in your models when decoding JSON using Swift 4
/// A type that has an "empty" representation.
public protocol EmptyRepresentable {
static func empty() -> Self
}
extension Array: EmptyRepresentable {
public static func empty() -> Array<Element> {
return Array()
}
}
@bnickel
bnickel / Queue Playground.swift
Last active June 23, 2020 16:33
Swift retry operation playground
import Foundation
protocol Completable {
func addCompletionOperation(on queue: OperationQueue, complete: @escaping (Self) -> Void) -> Operation
}
extension Completable where Self: Operation {
func addCompletionOperation(on queue: OperationQueue, complete: @escaping (Self) -> Void) -> Operation {
let completionOperation = BlockOperation {