-
Notifications
You must be signed in to change notification settings - Fork 0
Tap counter #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mmalykov
wants to merge
3
commits into
master
Choose a base branch
from
tap-counter
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Tap counter #1
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| // | ||
| // AppDelegate.swift | ||
| // tap_counter | ||
| // | ||
| // Created by Michail on 9/10/16. | ||
| // Copyright © 2016 mishaparadising. All rights reserved. | ||
| // | ||
|
|
||
| import UIKit | ||
|
|
||
| @UIApplicationMain | ||
| class AppDelegate: UIResponder, UIApplicationDelegate { | ||
|
|
||
| var window: UIWindow? | ||
|
|
||
|
|
||
| func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { | ||
| // START HERE | ||
| return true | ||
| } | ||
|
|
||
| func applicationWillResignActive(application: UIApplication) { | ||
| // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. | ||
| // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. | ||
| } | ||
|
|
||
| func applicationDidEnterBackground(application: UIApplication) { | ||
| // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. | ||
| // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. | ||
| } | ||
|
|
||
| func applicationWillEnterForeground(application: UIApplication) { | ||
| // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. | ||
| } | ||
|
|
||
| func applicationDidBecomeActive(application: UIApplication) { | ||
| // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. | ||
| } | ||
|
|
||
| func applicationWillTerminate(application: UIApplication) { | ||
| // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. | ||
| } | ||
|
|
||
|
|
||
| } | ||
|
|
68 changes: 68 additions & 0 deletions
68
tap_counter/Assets.xcassets/AppIcon.appiconset/Contents.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| { | ||
| "images" : [ | ||
| { | ||
| "idiom" : "iphone", | ||
| "size" : "29x29", | ||
| "scale" : "2x" | ||
| }, | ||
| { | ||
| "idiom" : "iphone", | ||
| "size" : "29x29", | ||
| "scale" : "3x" | ||
| }, | ||
| { | ||
| "idiom" : "iphone", | ||
| "size" : "40x40", | ||
| "scale" : "2x" | ||
| }, | ||
| { | ||
| "idiom" : "iphone", | ||
| "size" : "40x40", | ||
| "scale" : "3x" | ||
| }, | ||
| { | ||
| "idiom" : "iphone", | ||
| "size" : "60x60", | ||
| "scale" : "2x" | ||
| }, | ||
| { | ||
| "idiom" : "iphone", | ||
| "size" : "60x60", | ||
| "scale" : "3x" | ||
| }, | ||
| { | ||
| "idiom" : "ipad", | ||
| "size" : "29x29", | ||
| "scale" : "1x" | ||
| }, | ||
| { | ||
| "idiom" : "ipad", | ||
| "size" : "29x29", | ||
| "scale" : "2x" | ||
| }, | ||
| { | ||
| "idiom" : "ipad", | ||
| "size" : "40x40", | ||
| "scale" : "1x" | ||
| }, | ||
| { | ||
| "idiom" : "ipad", | ||
| "size" : "40x40", | ||
| "scale" : "2x" | ||
| }, | ||
| { | ||
| "idiom" : "ipad", | ||
| "size" : "76x76", | ||
| "scale" : "1x" | ||
| }, | ||
| { | ||
| "idiom" : "ipad", | ||
| "size" : "76x76", | ||
| "scale" : "2x" | ||
| } | ||
| ], | ||
| "info" : { | ||
| "version" : 1, | ||
| "author" : "xcode" | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| <?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
| <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM"> | ||
| <dependencies> | ||
| <deployment identifier="iOS"/> | ||
| <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/> | ||
| </dependencies> | ||
| <scenes> | ||
| <!--View Controller--> | ||
| <scene sceneID="EHf-IW-A2E"> | ||
| <objects> | ||
| <viewController id="01J-lp-oVM" sceneMemberID="viewController"> | ||
| <layoutGuides> | ||
| <viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/> | ||
| <viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/> | ||
| </layoutGuides> | ||
| <view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3"> | ||
| <rect key="frame" x="0.0" y="0.0" width="600" height="600"/> | ||
| <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> | ||
| <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/> | ||
| </view> | ||
| </viewController> | ||
| <placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/> | ||
| </objects> | ||
| <point key="canvasLocation" x="53" y="375"/> | ||
| </scene> | ||
| </scenes> | ||
| </document> |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| <?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
| <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r"> | ||
| <dependencies> | ||
| <deployment identifier="iOS"/> | ||
| <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/> | ||
| <capability name="Constraints to layout margins" minToolsVersion="6.0"/> | ||
| </dependencies> | ||
| <scenes> | ||
| <!--View Controller--> | ||
| <scene sceneID="tne-QT-ifu"> | ||
| <objects> | ||
| <viewController id="BYZ-38-t0r" customClass="ViewController" customModule="tap_counter" customModuleProvider="target" sceneMemberID="viewController"> | ||
| <layoutGuides> | ||
| <viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/> | ||
| <viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/> | ||
| </layoutGuides> | ||
| <view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC"> | ||
| <rect key="frame" x="0.0" y="0.0" width="600" height="600"/> | ||
| <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> | ||
| <subviews> | ||
| <label opaque="NO" userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="0" textAlignment="center" lineBreakMode="tailTruncation" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="xVW-2A-byH"> | ||
| <rect key="frame" x="271" y="242" width="59" height="115"/> | ||
| <fontDescription key="fontDescription" type="system" pointSize="96"/> | ||
| <nil key="highlightedColor"/> | ||
| </label> | ||
| <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="83S-Iy-79s"> | ||
| <rect key="frame" x="280" y="405" width="41" height="42"/> | ||
| <fontDescription key="fontDescription" type="system" pointSize="25"/> | ||
| <state key="normal" title="Tap"/> | ||
| <connections> | ||
| <action selector="tapButtonTapped:" destination="BYZ-38-t0r" eventType="touchUpInside" id="HjA-6i-U6J"/> | ||
| </connections> | ||
| </button> | ||
| <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="IJH-BP-p8Q"> | ||
| <rect key="frame" x="542" y="15" width="38" height="30"/> | ||
| <state key="normal" title="Undo"/> | ||
| <connections> | ||
| <action selector="undoBarButtonTapped:" destination="BYZ-38-t0r" eventType="touchUpInside" id="7Ya-5x-fKG"/> | ||
| </connections> | ||
| </button> | ||
| <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Counter" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="LAM-Kp-d3N"> | ||
| <rect key="frame" x="268" y="20" width="65" height="20"/> | ||
| <fontDescription key="fontDescription" type="system" weight="semibold" pointSize="17"/> | ||
| <color key="textColor" cocoaTouchSystemColor="darkTextColor"/> | ||
| <nil key="highlightedColor"/> | ||
| </label> | ||
| <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="a9p-Lu-2jQ"> | ||
| <rect key="frame" x="20" y="20" width="39" height="30"/> | ||
| <state key="normal" title="Reset"/> | ||
| <connections> | ||
| <action selector="resetBarButtonTapped:" destination="BYZ-38-t0r" eventType="touchUpInside" id="pAo-Gu-xVS"/> | ||
| </connections> | ||
| </button> | ||
| </subviews> | ||
| <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/> | ||
| <constraints> | ||
| <constraint firstItem="IJH-BP-p8Q" firstAttribute="top" secondItem="y3c-jy-aDJ" secondAttribute="bottom" constant="-5" id="DTE-Lx-zn4"/> | ||
| <constraint firstItem="83S-Iy-79s" firstAttribute="centerX" secondItem="xVW-2A-byH" secondAttribute="centerX" id="Vis-Vk-nPD"/> | ||
| <constraint firstItem="xVW-2A-byH" firstAttribute="centerY" secondItem="8bC-Xf-vdC" secondAttribute="centerY" id="WbD-mo-NAN"/> | ||
| <constraint firstItem="xVW-2A-byH" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="aiQ-Dp-ROS"/> | ||
| <constraint firstItem="a9p-Lu-2jQ" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" constant="20" id="b2b-k3-Awp"/> | ||
| <constraint firstItem="xVW-2A-byH" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="hBV-gr-aYR"/> | ||
| <constraint firstItem="83S-Iy-79s" firstAttribute="top" secondItem="xVW-2A-byH" secondAttribute="bottom" constant="48" id="kNe-RW-qYx"/> | ||
| <constraint firstAttribute="trailing" secondItem="IJH-BP-p8Q" secondAttribute="trailing" constant="20" id="ltE-rN-YxO"/> | ||
| <constraint firstItem="LAM-Kp-d3N" firstAttribute="top" secondItem="8bC-Xf-vdC" secondAttribute="top" constant="20" id="nJG-dW-CqY"/> | ||
| <constraint firstItem="LAM-Kp-d3N" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="qlT-wY-4HN"/> | ||
| <constraint firstItem="a9p-Lu-2jQ" firstAttribute="top" secondItem="8bC-Xf-vdC" secondAttribute="topMargin" constant="20" id="r3Q-bb-UpN"/> | ||
| </constraints> | ||
| </view> | ||
| <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/> | ||
| <size key="freeformSize" width="600" height="600"/> | ||
| <connections> | ||
| <outlet property="tapCounterLabel" destination="xVW-2A-byH" id="D9n-BG-eCz"/> | ||
| </connections> | ||
| </viewController> | ||
| <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/> | ||
| </objects> | ||
| <point key="canvasLocation" x="551" y="173"/> | ||
| </scene> | ||
| </scenes> | ||
| </document> |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
| <plist version="1.0"> | ||
| <dict> | ||
| <key>CFBundleDevelopmentRegion</key> | ||
| <string>en</string> | ||
| <key>CFBundleExecutable</key> | ||
| <string>$(EXECUTABLE_NAME)</string> | ||
| <key>CFBundleIdentifier</key> | ||
| <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||
| <key>CFBundleInfoDictionaryVersion</key> | ||
| <string>6.0</string> | ||
| <key>CFBundleName</key> | ||
| <string>$(PRODUCT_NAME)</string> | ||
| <key>CFBundlePackageType</key> | ||
| <string>APPL</string> | ||
| <key>CFBundleShortVersionString</key> | ||
| <string>1.0</string> | ||
| <key>CFBundleSignature</key> | ||
| <string>????</string> | ||
| <key>CFBundleVersion</key> | ||
| <string>1</string> | ||
| <key>LSRequiresIPhoneOS</key> | ||
| <true/> | ||
| <key>UILaunchStoryboardName</key> | ||
| <string>LaunchScreen</string> | ||
| <key>UIMainStoryboardFile</key> | ||
| <string>Main</string> | ||
| <key>UIRequiredDeviceCapabilities</key> | ||
| <array> | ||
| <string>armv7</string> | ||
| </array> | ||
| <key>UISupportedInterfaceOrientations</key> | ||
| <array> | ||
| <string>UIInterfaceOrientationPortrait</string> | ||
| <string>UIInterfaceOrientationLandscapeLeft</string> | ||
| <string>UIInterfaceOrientationLandscapeRight</string> | ||
| </array> | ||
| <key>UISupportedInterfaceOrientations~ipad</key> | ||
| <array> | ||
| <string>UIInterfaceOrientationPortrait</string> | ||
| <string>UIInterfaceOrientationPortraitUpsideDown</string> | ||
| <string>UIInterfaceOrientationLandscapeLeft</string> | ||
| <string>UIInterfaceOrientationLandscapeRight</string> | ||
| </array> | ||
| </dict> | ||
| </plist> |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| // | ||
| // ViewController.swift | ||
| // tap_counter | ||
| // | ||
| // Created by Michail on 9/10/16. | ||
| // Copyright © 2016 mishaparadising. All rights reserved. | ||
| // | ||
|
|
||
| import UIKit | ||
|
|
||
| class ViewController: UIViewController { | ||
|
|
||
| // MARK: Outlets | ||
| @IBOutlet weak var tapCounterLabel: UILabel!; | ||
|
|
||
| // MARK: Properties | ||
| var counter = 0; | ||
|
|
||
| // MARK: Init | ||
| override func viewDidLoad() { | ||
| super.viewDidLoad() | ||
|
|
||
| tapCounterLabel.text = String(counter); | ||
| } | ||
|
|
||
| override func didReceiveMemoryWarning() { | ||
| super.didReceiveMemoryWarning() | ||
| } | ||
|
|
||
|
|
||
| // MARK: Actions | ||
| @IBAction func tapButtonTapped(sender: UIButton) { | ||
| counter += 1; | ||
| tapCounterLabel.text = String(counter); | ||
| } | ||
|
|
||
| @IBAction func resetBarButtonTapped(sender: UIButton) { | ||
| counter = 0; | ||
| tapCounterLabel.text = String(counter); | ||
| } | ||
|
|
||
| @IBAction func undoBarButtonTapped(sender: UIButton) { | ||
| if(counter > 0) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could also be You can read about ternary operator here |
||
| counter -= 1; | ||
| } | ||
|
|
||
| tapCounterLabel.text = String(counter); | ||
| } | ||
| } | ||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
| <plist version="1.0"> | ||
| <dict> | ||
| <key>CFBundleDevelopmentRegion</key> | ||
| <string>en</string> | ||
| <key>CFBundleExecutable</key> | ||
| <string>$(EXECUTABLE_NAME)</string> | ||
| <key>CFBundleIdentifier</key> | ||
| <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||
| <key>CFBundleInfoDictionaryVersion</key> | ||
| <string>6.0</string> | ||
| <key>CFBundleName</key> | ||
| <string>$(PRODUCT_NAME)</string> | ||
| <key>CFBundlePackageType</key> | ||
| <string>BNDL</string> | ||
| <key>CFBundleShortVersionString</key> | ||
| <string>1.0</string> | ||
| <key>CFBundleSignature</key> | ||
| <string>????</string> | ||
| <key>CFBundleVersion</key> | ||
| <string>1</string> | ||
| </dict> | ||
| </plist> |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| // | ||
| // tap_counterTests.swift | ||
| // tap_counterTests | ||
| // | ||
| // Created by Michail on 9/10/16. | ||
| // Copyright © 2016 mishaparadising. All rights reserved. | ||
| // | ||
|
|
||
| import XCTest | ||
| @testable import tap_counter | ||
|
|
||
| class tap_counterTests: XCTestCase { | ||
|
|
||
| override func setUp() { | ||
| super.setUp() | ||
| // Put setup code here. This method is called before the invocation of each test method in the class. | ||
| } | ||
|
|
||
| override func tearDown() { | ||
| // Put teardown code here. This method is called after the invocation of each test method in the class. | ||
| super.tearDown() | ||
| } | ||
|
|
||
| func testExample() { | ||
| // This is an example of a functional test case. | ||
| // Use XCTAssert and related functions to verify your tests produce the correct results. | ||
| } | ||
|
|
||
| func testPerformanceExample() { | ||
| // This is an example of a performance test case. | ||
| self.measureBlock { | ||
| // Put the code you want to measure the time of here. | ||
| } | ||
| } | ||
|
|
||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No semicolons (please fix everywhere by search & replace
;with empty line)