Skip to content

Instantly share code, notes, and snippets.

@SergLam
Created December 6, 2019 06:41
Show Gist options
  • Save SergLam/d26b3fe7b11cd3fb1d86c01f06b5f487 to your computer and use it in GitHub Desktop.
Save SergLam/d26b3fe7b11cd3fb1d86c01f06b5f487 to your computer and use it in GitHub Desktop.
Stored properties in extension hack:
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
var testStr = ""
var testStr2 = "131231"
testStr.test = 20
testStr2.test = 40
debugPrint(testStr.test)
debugPrint(testStr2.test)
return true
}
}
extension String {
private struct Structure {
static var dict = [String: Int]()
}
var test: Int? {
get {
Structure.dict[debugDescription]
}
set {
Structure.dict[debugDescription] = newValue
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment