Open regan-sarwas opened 7 years ago
Same is true of survey created in SelectSurveyVC.
While the suggestions above are a good idea, I think we are safe in the meantime, because all the survey init methods will either create a unique URL in the private survey folder (withProtocol or withArchive), or will be called with a url that cannot possibly be in the private survey folder (open from email/safari), for which a unique url in the private survey folder will be generated.
This might be impossible, but that isn't obvious.
If they are, then the AppDelegate should use the existing survey object.
Basically, the survey collection should be the only one to create survey objects. The AppDelegate should ask the survey collection to create them from the URL it has, to ensure that they are not already in the survey collection.
Since survey objects should be singletons for their underlying URL to avoid problems with opening/closing the UIManagedDocument/ManagedObjectModel, the Survey class should create a dictionary of urls to survey objects as it creates a survey object at a URL, and always return the same object if anyone tries to create a new survey at the same URL.