Skip to content

Instantly share code, notes, and snippets.

@priteshshah1983
priteshshah1983 / lenses.swift
Last active November 29, 2017 22:54
Lenses - Re-imagined with Swift 4
// Motivation:
// http://chris.eidhof.nl/post/lenses-in-swift/
// https://www.youtube.com/watch?v=ofjehH9f-CU&feature=youtu.be
protocol Changeable {
func changed<A>(changes: [KeyPath<Self, A>: A]) -> Self
}
extension Changeable {
func changed<A>(changes: [KeyPath<Self, A>: A]) -> Self {
I was referring to this code:
// This is of the form: TEAMID.mSSO
#define kmSSOKeychainGroup @"3Q4M6DQ9WM.mSSO"
which is used here:
[keychainSearch setObject:kmSSOKeychainGroup forKey:(id)kSecAttrAccessGroup]; // inform the search that we're using the shared keychain
The use case I was talking about: I want to create a static library with the keychain stuff for two customers with team ids: TEAMID1 and TEAMID2.
I would have to somehow read the appropriate TEAMID from within the app which contains the static library. One option could be to have the customer define the TEAMID in a .plist file or something. But, it would be nice if I could just read the TEAMID during runtime.