Watch OS 1.0.1 changed the lifecycle for page-based apps: now willActivate
/didActivate
get called for the next page to preload it.
I was previously calling updateUserActivity:userInfo:webpageURL:
in each of my page's willActivate
methods, supplying different userInfo
for each page. But now that userInfo
gets stepped on by the next page's call to the same method in willActivate
.
Any idea how to get around this?
I think I have a better solution. It consists in maintaining a Bool in each page controller that tells whether the controller is active (displayed), and in keeping a value for the NSUserActivity that needs to be updated to the OS
Now you can «tag» your user activity wherever you want in the interface controller code by simply assigning a value for currentUserActivity. For instance it can be in the awakeWithContext: method
The user activity will be reported only if currentUserActivity is set and the controller is active (displayed). Note that the way it is implemented above allows you to invalidateUserActivity by simply setting self.currentUserActivity = nil when your controller is active.