Skip to content

Instantly share code, notes, and snippets.

@vtourraine
Created March 8, 2016 21:12
Show Gist options
  • Save vtourraine/86f8871fdbbb696064b2 to your computer and use it in GitHub Desktop.
Save vtourraine/86f8871fdbbb696064b2 to your computer and use it in GitHub Desktop.
Games Keeper for Apple Watch
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder.WatchKit.Storyboard" version="3.0" toolsVersion="9532" systemVersion="15D21" targetRuntime="watchKit" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="AgC-eL-Hgc">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBWatchKitPlugin" version="9515"/>
</dependencies>
<scenes>
<!--Games-->
<scene sceneID="aou-V4-d1y">
<objects>
<controller title="Games" id="AgC-eL-Hgc" customClass="InterfaceController" customModule="GamesKeeperWatch" customModuleProvider="target">
<items>
<group width="1" height="1" alignment="left" layout="vertical" id="MZJ-RV-5I2">
<items>
<label width="1" height="0.40000000000000002" alignment="left" text="0" textAlignment="center" id="8Zp-qC-Wlv">
<color key="textColor" red="1" green="0.70588235290000001" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="font" type="system" pointSize="52"/>
</label>
<group width="1" height="0.59999999999999998" alignment="left" id="MpW-xp-I4F">
<items>
<button width="0.40000000000000002" height="1" alignment="left" title="−" id="UKP-O4-oGe">
<color key="backgroundColor" red="0.3803921569" green="0.2156862745" blue="0.82745098039999998" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="font" type="boldSystem" pointSize="52"/>
<connections>
<action selector="decrementScore" destination="AgC-eL-Hgc" id="9hw-eD-a8E"/>
</connections>
</button>
<button width="0.59999999999999998" height="1" alignment="left" title="+" id="O6W-17-t8a">
<color key="backgroundColor" red="0.3803921569" green="0.2156862745" blue="0.82745098039999998" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="font" type="boldSystem" pointSize="52"/>
<connections>
<action selector="incrementScore" destination="AgC-eL-Hgc" id="2j8-Rw-0uA"/>
</connections>
</button>
</items>
</group>
</items>
</group>
</items>
<menu key="menu" id="Lzt-a8-TzU">
<items>
<menuItem title="Reset" icon="resume" id="cC8-O9-FFS">
<connections>
<action selector="resetScore" destination="AgC-eL-Hgc" id="DTo-AF-ZlD"/>
</connections>
</menuItem>
</items>
</menu>
<connections>
<outlet property="scoreLabel" destination="8Zp-qC-Wlv" id="YJh-0R-TUb"/>
</connections>
</controller>
</objects>
</scene>
</scenes>
</document>
//
// InterfaceController.swift
// GamesKeeperWatch Extension
//
// Created by Vincent Tourraine on 29/02/16.
// Copyright © 2016 Studio AMANgA. All rights reserved.
//
import WatchKit
import Foundation
class InterfaceController: WKInterfaceController {
@IBOutlet var scoreLabel: WKInterfaceLabel!
var score: Int = 0 {
didSet {
scoreLabel .setText(String(score))
}
}
// MARK: - Actions
@IBAction func decrementScore() {
score = score - 1
}
@IBAction func incrementScore() {
score = score + 1
}
@IBAction func resetScore() {
score = 0
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment