Skip to content

Instantly share code, notes, and snippets.

@PeterLi
PeterLi / Encrypted Realm with secret in keychain in app supporting background fetch intermittently causes realm to fail to initialize and crash app at try! - SOLVED
Last active February 8, 2023 20:53
Encrypted Realm with secret in keychain in app supporting background fetch intermittently causes realm to fail to initialize and crash app at try! - SOLVED
This is like a drop-in replacement for realms example swift project enabling encryption using the function getKey().
https://github.com/realm/realm-cocoa/blob/master/examples/ios/swift/Encryption/ViewController.swift
The following swift function is a drop in replacement, it documents the painful experience of an issue
which has been unsolved for years till crashlytics revealed a very useful hint, which lead to the root cause
and fix.
Comments included for education on what the symptoms were, the cause and fix and other notes.
@douglashill
douglashill / KeyboardTableView.swift
Last active March 30, 2023 22:01
A UITableView that allows navigation and selection using a hardware keyboard.
// Douglas Hill, December 2018
// Made for https://douglashill.co/reading-app/
// Find the latest version of this file at https://github.com/douglashill/KeyboardKit
import UIKit
/// A table view that allows navigation and selection using a hardware keyboard.
/// Only supports a single section.
class KeyboardTableView: UITableView {
// These properties may be set or overridden to provide discoverability titles for key commands.
@vincent-peng
vincent-peng / Data+HexEncodedString.swift
Last active November 26, 2023 14:28
Convert Data to hex string in Swift
// http://stackoverflow.com/a/40089462
extension Data {
func hexEncodedString() -> String {
return map { String(format: "%02hhx", $0) }.joined()
}
}