ããã«ã¡ã¯ã22年度æ°åã¨ãã¦FIXERã«å ¥ç¤¾ãã¾ããã寺ç°ã§ãã
ã¿ã¤ãã«ã«ãæ¸ãã¦ãã¾ãããä»åã¯Apple Watchã¢ããªã®éçºã«ã¤ãã¦æ¸ãã¦ãããã¨æãã¾ããä»åã®ãã¼ãã¯ãiPhoneã¨Apple Watchéã®éä¿¡ãã§ãã
ã¯ããã«
ãªããApple Watchã¢ããªã®éçºã«ã¤ãã¦æ¸ããã¨æã£ãã®ãããã®çç±ã¯åç´ã§ãã
æ å ±ãçç¡ï¼ï¼
ããã«å°½ãã¾ãããApple Watchã¢ããªéçºãã§æ¤ç´¢ãã¦ãããããããæ å ±ã¯ãå¤ãããããã¯ãä¸ååãã§ãã
ãã®ãããããéçºãããã¨æã£ã¦ããçµå±ã©ãããã°ããã®ï¼ãã¨ãªã£ã¦ãã¾ãã®ãç¾ç¶ã§ãã大å¦çæ代ã®åãããã§ããã
ä»åã¯ããããªç¾ç¶ãå¤ããä¸æã¨ãã¦ããã®è¨äºãæ稿ããã¦ããã ãã¾ãã
æºåç©
å¿ è¦ãªæ©æã¯ä»¥ä¸ã®ããã«ãªã£ã¦ãã¾ãã
- Mac â»å¿ é
PCã«é¢ãã¦ã¯ãMacéå®ã¨ãªãã¾ãã(ä»åå©ç¨ããXcodeããWindowsãã·ã³ã«ã¯ã¤ã³ã¹ãã¼ã«ã§ããªããã¨ãçç±ã§ãã)
Xcodeã®ã¤ã³ã¹ãã¼ã«
ã¾ãããXcodeããMacã«ã¤ã³ã¹ãã¼ã«ãã¦ãããã¨æãã¾ããâ»ãã§ã«ãXcodeããã¤ã³ã¹ãã¼ã«ãã¦ããæ¹ã¯ãé£ã°ãã¦ããã ãã¦å¤§ä¸å¤«ã§ãã
App Storeãéããæ¤ç´¢ã¿ãã§ãXcodeãã¨æ¤ç´¢ãã¦ãã ãããããã«ãããããã¨æãã¾ãã®ã§ãã¤ã³ã¹ãã¼ã«ããé¡ããã¾ããâ»å®¹éã大ããã®ã§ãå°ãæéããããã¾ãã
ããã¸ã§ã¯ãä½æ
Xcodeã®ã¤ã³ã¹ãã¼ã«ãçµããã¾ããããããã¸ã§ã¯ããä½æãã¦ããã¾ãã
Xcodeãèµ·åããã¨ã以ä¸ã®ãããªç»é¢ã表示ãããã®ã§ããCreate a new Xcode projectããé¸æãã¦ãã ããã
次ã«ãä½æããããã¸ã§ã¯ãã®ç¨®é¡ãé¸æãã¾ããApple Watchãå©ç¨ããã¢ããªã¯ã以ä¸ã®2種é¡ã«åé¡ããã¾ãã
- Apple Watchã®ã¿ã§åä½ããã¢ããª
- Apple Watchã¨iPhoneãé£æºããåä½ããã¢ããª
ä»åã¯ãå¾è ã®ãApple Watchã¨iPhoneãé£æºããåä½ããã¢ããªããä½æãã¦ããã¾ãã®ã§ããiOS App with Watch Appããé¸æãã¾ããé¸æãã¾ãããããNextããæ¼ãã¾ãã
æå¾ã«ãããã¸ã§ã¯ãã«é¢ããç´°ããè¨å®ãè¡ãã¾ãã以ä¸ã®ããã«è¨å®ãã¦ãã ããã使ç¨è¨èªã¯ãSwiftãã§ãã
ä¸å³ã®è¨å®å¾ããNextããæ¼ãã¨ãããã¸ã§ã¯ããä½æããã¾ãã
UIã®è¨å®
ããããã¯UIã®ç°¡åãªè¨å®ãè¡ã£ã¦ããã¾ããããã®åã«ãä»åä½æããã¢ããªãç°¡åã«èª¬æãã¦ããã¾ãã
ä»åä½æããã¢ããªã¯ãiPhoneå´ã§ãã¿ã³ãæ¼ãã¨ãApple Watchå´ã®æ°åãã1ãã¤å¢ãã¦ããã¨ããã¢ããªã§ãããã®ããã以ä¸ã®ãªãã¸ã§ã¯ããå¿ è¦ã«ãªãã¾ãã
iPhoneå´
- Apple Watchå´ã®æ°åãå¢ãããã¿ã³
Apple Watchå´
- iPhoneå´ã®ãã¿ã³æ¼ä¸ã«åããã¦ã1ãã¤æ°åãå¢ããã©ãã«
iPhoneå´ã®UI
ã¾ããiPhoneå´ã®è¨å®ãè¡ãã¾ãããMain.storyboardããéãã以ä¸ã®æä½ãè¡ã£ã¦ãã ããã
ä¸å³ã«ç¤ºãããã«ãéä¿¡ãã¨ãããã¿ã³ã表示ãããããiPhoneå´ã®è¨å®ã¯å®äºã§ãã
Apple Watchå´ã®UI
次ã«ãApple Watchå´ã®è¨å®ãè¡ãã¾ãããInterface.storyboardããéãã以ä¸ã®æä½ãè¡ã£ã¦ãã ããã
ä¸å³ã«ç¤ºãããã«ãã«ã¦ã³ããã¨ããã©ãã«ã表示ãããããApple Watchå´ã®è¨å®ã¯å®äºã§ãã
ã³ã¼ãã£ã³ã°ã»iPhoneå´ã®å¦ç
UIã®è¨å®ãå®äºããã®ã§ãããããã¯ã³ã¼ããæ¸ãã¦ããã¾ãã(æ¬ç« ã§å©ç¨ãããã¡ã¤ã«ã¯ãViewController.swiftãã§ãã)
ã³ã¼ããæ¸ãã«ããããã¾ãããªãã¸ã§ã¯ãããViewController.swiftãã«æ¥ç¶ãã¾ããä»åã¯ããã¿ã³æ¼ä¸æã®å¦çãè¨è¼ãã¦ããã®ã§ããã¿ã³ããViewController.swiftãã«æ¥ç¶ãã¾ãã
ã¾ããæ¥ç¶æã«è¡¨ç¤ºããããã¤ã¢ãã°ã®ãNameãã¯ããsendButtonãã«ãã¦ãã ããã
ä¸å³ã®ããã«ãªã£ã¦ãããã¨ã確èªå¾ããConnectããæ¼ãã¦ãã ãããæ¥ç¶ãå®äºããã¨ãã@IBAction func sendButton(_sender Any){ }ãã¨ããã³ã¼ããè¨è¼ããã¾ãã
次ã«ãApple Watchã¨éä¿¡ãè¡ãã«ããããå¿ è¦ãªãã¬ã¼ã ã¯ã¼ã¯ãã¤ã³ãã¼ããã¾ãããViewController.swiftãã以ä¸ã®ããã«æ¸ãæãã¦ãã ããããWatchConnectivityãããWCSessionDelegateãã追å ããå½¢ã«ãªãã¾ãã
ããã¾ã§è¨å ¥ããã¨ã以ä¸ã®ãããªã¨ã©ã¼ã¡ãã»ã¼ã¸ã表示ãããã¨æãã®ã§ããFixããæ¼ãã¦ãã ãããå¿ è¦ãªã³ã¼ããèªåã§è¨è¼ããã¾ãã
次ã«ããoverride func viewDidLoad() { }ãå ã«ã以ä¸ã®ã³ã¼ããè¨è¼ãã¦ãã ããã以ä¸ã®ã³ã¼ããè¨è¼ããªãã¨ãWCSesssionãæ©è½ããªãã®ã§ãã注æãã ããã
ããã§ãiPhoneããApple Watchã«åãããã¼ã¿ãéä¿¡ããããã®æºåãæ´ãã¾ããã
ä»åº¦ã¯ãå®éã«Apple Watchã«éä¿¡ãããã¼ã¿ãå®ç¾©ãã¦ããã¾ããä»åã¯ãIntåã®å¤æ°ãå®ç¾©ããApple Watchã«éã£ã¦ã¿ã¾ãããã
ãsendIntãã¨ããååã®å¤æ°ãå®ç¾©ãã¦ãã ããã
æå¾ã«ãå®ç¾©ãããsendIntããApple Watchã«éä¿¡ããå¦çãè¨è¼ãã¦ããã¾ããã @IBAction func sendButton(_sender Any){ } ãå ã«ä»¥ä¸ã®ã³ã¼ããè¨è¼ãã¦ãã ãããããã§è¨è¼ããã³ã¼ãã¯ããã¿ã³ãæ¼ããããã³ã«å®è¡ãããå¦çã«ãªãã¾ãã
ããã§ããã¿ã³ãæ¼ããã³ã«ããsendIntããApple Watchã«éä¿¡ãããå¦çãå®æãã¾ããã
ã³ã¼ãã£ã³ã°ã»Apple Watchå´ã®å¦ç
次ã«ãApple Watchå´ã®å¦çãè¨è¼ãã¦ããã¾ãã (æ¬ç« ã§å©ç¨ãããã¡ã¤ã«ã¯ãInterfaceController.swiftãã§ãã)
ã¾ããiPhoneå´ã¨åæ§ã«ãWatchConnectivityãããWCSessionDelegateãããInterfaceController.swift ãã«è¿½å ãã¾ãã
次ã«ãå©ç¨ãããªãã¸ã§ã¯ãã ãInterfaceController.swiftãã«æ¥ç¶ãã¾ããä»åã¯ãã©ãã«ãæ¥ç¶ãã¾ããæ¥ç¶ã®æµãã¯iPhoneå´ã¨åæ§ã§ãã
ã¾ããæ¥ç¶æã«è¡¨ç¤ºããããã¤ã¢ãã°ã®ãNameãã¯ããreceiveLabelãã«ãã¦ãã ããã
ä¸å³ã®ããã«ãªã£ã¦ãããã¨ã確èªå¾ããConnectããæ¼ãã¦ãã ããã
æå¾ã«ãiPhoneå´ããéããã¦ãããã¼ã¿ãApple Watchå´ã§åãåãå¦çãè¨è¼ãã¦ããã¾ãã以ä¸ã®ã³ã¼ããè¨è¼ãã¦ãã ããã
ããã§ãiPhoneå´ããéããã¦ãããã¼ã¿ããApple Watchå´ã§åãåããã¨ãã§ãã¾ãã
ãããã«
ããã§ãiPhoneå´ã§ãã¿ã³ãæ¼ãã¨ãApple Watchå´ã®æ°åãã1ãã¤å¢ãã¦ããã¢ããªãå®æãã¾ããã
好è©ã§ããããå®æ©ã§ä»åã®ã¢ããªãåä½ãããæ¹æ³ããã³ã¼ãã®è§£èª¬ãªã©ã«é¢ãã¦ãå¥è¨äºã¨ãã¦æãã¦ãããã¨æãã¾ãã