Created
August 29, 2016 19:03
-
-
Save omgbbqhaxx/c86ffee5d241ec7d6f5754669ce6783b to your computer and use it in GitHub Desktop.
Swift open 5 minutes session.
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 | |
| // TimeLapse | |
| // | |
| // Created by Yasin Aktimur on 29.08.2016. | |
| // Copyright © 2016 Yasin Aktimur. All rights reserved. | |
| // | |
| import UIKit | |
| class ViewController: UIViewController { | |
| var timer = NSTimer() | |
| var suan = NSDate() | |
| var besdksonra = NSDate() | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| let calendar = NSCalendar.currentCalendar() | |
| self.suan = NSDate() | |
| besdksonra = calendar.dateByAddingUnit(.Minute, value: 5, toDate: suan, options: [])! | |
| timer = NSTimer.scheduledTimerWithTimeInterval(10.0, target: self, selector: #selector(self.testordie), userInfo: nil, repeats: true) | |
| self.timer.fire() | |
| // Do any additional setup after loading the view, typically from a nib. | |
| } | |
| func testordie(){ | |
| self.suan = NSDate() | |
| if self.besdksonra.timeIntervalSince1970 < suan.timeIntervalSince1970 { | |
| print("5 dk geçti") | |
| self.timer.invalidate() | |
| }else{ | |
| print("CONT..") | |
| } | |
| } | |
| 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