#Making Use of Glances in Apple Watch Apps
Finally in our Apple Watch App explorations, one of the features we really wanted to try out was glances. These allow people a "quick look" at some important information. In Whiskr we wanted people to be able to see the picture they last looked at quickly again. Maybe to help people check if a cat in front of them matches the one they saw on their screen.
To get started with glances, we need to save the last image viewed. We will need to use the information from this blog on how to save data between iPhone and Apple Watch app using User Preferences.
Next, we need to open the Apple Watch App Storyboard and navigate to the glance interface controller. There are some annoying storyboard restrictions with the glances, you have to have two different groups, you can't have one single group. You also can't have your content scrolling, it has to fit exactly on the view.
Our Glance storyboard with a separate text and image groups.
Inside our GlanceInterfaceController.m file, we can set up a function to get the saved image from User Preferences (using the same blog post). I also saved a separate String value for the title and copyright information for each picture, so this could be easily viewable.
The complicated bit in glances is how to update the information, e.g. how often should we update the picture? Apple recommend setting up a NSTimer to refresh all the data, how often you want to refresh could be up to you. We decided on 30 seconds.
//schedule a time to check every 5 seconds
_timer = [NSTimer scheduledTimerWithTimeInterval:5 target:self
selector:@selector(getUserDefaults) userInfo:nil repeats:YES];
You also need to remember to stop the timer when the glance closes:
//kill our timer!
[_timer invalidate];
We need to tell our emulator to run the "glances" mode and not the proper Apple Watch App. To do this click on the target for the emulator (bit to the left of which device your going to run on) and press edit scheme.
Here you want to change the executable to the "glance":
edit apple watch scheme
Hopefully that demonstrates how some of the key features of Whiskr work so you too can build your own awesome Apple Watch Apps. We're now waiting excitedly to get our hands our own Apple Watch!