This is an overview of watchOS 2 designed to give you the head start you need to start building! Learn about how to design for the Apple Watch, the different UI components included, how your Apple Watch works together (and independently) with your iOS app, and more!
29. // iOS app
struct Session {
let startTime: NSDate
let endTime: NSDate
let description: String
let location: String
let speaker: Speaker?
}
// Watch App
struct Session {
let startTime: NSDate
let endTime: NSDate
let location: String
let speaker: Speaker?
let index: Int
}
40. // check needed for iOS App Only
if WCSession.isSupported() {
// activate session for both!
let session = WCSession.defaultSession()
session.delegate = self
session.activateSession()
}
41. import WatchConnectivity
class WatchSessionManager: NSObject, WCSessionDelegate {
static let sharedManager = WatchSessionManager()
private override init() {
super.init()
}
private let session: WCSession? =
WCSession.isSupported() ?
WCSession.defaultSession() : nil
// no need for the check on the Watch App:
// private let session = WCSession.defaultSession()
func startSession() {
session?.delegate = self
session?.activateSession()
}