Reputation: 358
I attempting to grasp some kind of unit tests, so we create mock user defaults.
class MockUserDefaults: UserDefaults {
var gameStyleChanged = 0
override func set(_ value: Int, forKey defaultName: String) {
if defaultName == "something" {
someStyleChanged += 1
}
}
}
right after in setup() i create
mockUserDefaults = MockUserDefaults(suiteName: "testing")!
So i confused i can't understand full meaning of suiteName i've read official documentation but it is not clear enough, please help
Upvotes: 6
Views: 4363
Reputation: 9484
suiteName:is kind of an identifier which helps you create preferences(UserDefaults) store. By using a particular suiteName, you are creating a preferences store, that is not bounded to a particular application (whereas standard UserDefaults are different for every application). Because of this reason, you can create a store, that can be shared between different app/extensions.
Upvotes: 7