why userDataStore doesn't point to profileInteractor.userDataStore !?
In this line:
var profileInteractor = ProfileInteractor(userDataStore: UserDataStore())
You created a new ProfileInteractor object and a new UserDataStore object. Then, you made profileInteractor refer to the ProfileInteractor object.
In the next line:
var userDataStore = profileInteractor.userDataStore
You are making userDataStore refer to the same object as profileInteractor.userDataStore. Now anything you do to the UserDataStore object by using userDataStore will be reflected on profileInteractor.userDataStore because they are essentially the same thing.
However, this line changes everything:
profileInteractor.userDataStore = nil
You made profileInteractor.userDataStore refer to nothing. This DOES NOT mean that the UserDataStore object is destroyed. This just means that you no longer can use profileInteractor.userDataStore to access the UserDataStore object. But guess what is still referring to the UserDataStore object? userDataStore!
So the answer to your question is that userDataStore did point to the same object as profileInteractor.userDataStore, until you set profileInteractor.userDataStore to nil.
What must I do, that userDataStore points to it?
Well, you already did. You just made profileInteractor.userDataStore point to something else in the next line of code.
If you want a local variable to always point to the same thing that another local variable points to, your code can get quite messy, like in Ankit Thakur's answer, with unsafe pointers and stuff. If you are passing the variable to a method, you can use the inout keyword.