Storing information to show within your glance controller
In this section, we will take a look at how we can use the NSStandardUserDefaults
class to store the selected shopping list item when the user taps on a specific row within the WKInterfaceTable
controller. This will then be displayed within the glance interface controller's WKInterfaceController
class:
Open the
InterfaceController.swift
file located within the ShoppingList WatchKit Extension group in the project navigation window.Next, locate the
didSelectRowAtIndex
method and enter the following highlighted code snippet:// MARK: WKInterfaceTable Delegate Callbacks // Handle when a row has been selected within our table override func table(table: WKInterfaceTable, didSelectRowAtIndex rowIndex: Int) { // Send the product to be charged by sending the product as // a dictionary object, // and then converting it to a 'Product' type value in our // application delegate. // We will then have our iOS app...