Created
December 6, 2019 06:41
-
-
Save SergLam/d26b3fe7b11cd3fb1d86c01f06b5f487 to your computer and use it in GitHub Desktop.
Stored properties in extension hack:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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