Last active
March 17, 2016 16:43
-
-
Save Appletone/4fd775545926b9a95442 to your computer and use it in GitHub Desktop.
評估你的 App 是否加入 Apple Watch 功能
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ViewController.swift | |
// WatchPairedExample | |
// | |
// Created by 張 景隆 on 2015/11/26. | |
// Copyright © 2015年 張 景隆. All rights reserved. | |
// | |
import UIKit | |
import WatchConnectivity | |
class ViewController: UIViewController, WCSessionDelegate { | |
@IBOutlet weak var label: UILabel! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view, typically from a nib. | |
if WCSession.isSupported() { | |
let session = WCSession.defaultSession() | |
session.delegate = self | |
session.activateSession() | |
if session.paired { | |
label.text = "有配對 Apple Watch" | |
} | |
else { | |
label.text = "無 Apple Watch" | |
} | |
} | |
} | |
override func didReceiveMemoryWarning() { | |
super.didReceiveMemoryWarning() | |
// Dispose of any resources that can be recreated. | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment