Skip to content

Instantly share code, notes, and snippets.

@chriseidhof
chriseidhof / sample.swift
Last active June 11, 2024 06:11
View Inspection
import SwiftUI
struct SizeKey: PreferenceKey {
static func reduce(value: inout CGSize?, nextValue: () -> CGSize?) {
value = value ?? nextValue()
}
}
struct ContentView: View {
@State var width: CGFloat? = nil
var body: some View {
@nyg
nyg / MemoryAddress.swift
Last active June 26, 2024 16:44
Get the memory address of both class and structure instances in Swift.
// https://stackoverflow.com/a/45777692/5536516
import Foundation
struct MemoryAddress<T>: CustomStringConvertible {
let intValue: Int
var description: String {
let length = 2 + 2 * MemoryLayout<UnsafeRawPointer>.size
@depth42
depth42 / gist:7356279
Created November 7, 2013 15:16
Workaround for XCTest not reporting failing NSAssertions.
#import "PWAssertionHandler.h"
#import "PWLog.h"
#import "Intercept_objc_exception_throw.h"
#import <objc/runtime.h>
#import "PWDispatch.h"
#ifndef NDEBUG
@interface NSAssertionHandler (PWExtensions)
@property (nonatomic, readonly) BOOL isPWHandler;
@hujunfeng
hujunfeng / udid-faq.md
Last active January 24, 2024 14:15
UDID, identifierForVendor and advertisingIdentifier FAQ

What's the difference between UUID, GUID and UDID?

  • UUID (Universally Unique Identifier): A sequence of 128 bits that can guarantee uniqueness across space and time, defined by [RFC 4122][rfc4122].

  • GUID (Globally Unique Identifier): Microsoft's implementation of the UUID specification; often used interchangeably with UUID.

  • UDID _(Unique Device Identifier)): A sequence of 40 hexadecimal characters that uniquely identify an iOS device (the device's Social Security Number, if you will). This value can be retrieved through iTunes, or found using UIDevice -uniqueIdentifier. Derived from hardware details like MAC address.

Is UDID deprecated?