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
    
  
  
    
  | // | |
| // TimeCounter.swift | |
| // test | |
| // | |
| // Created by Kolathee Payuhawattana on 15/2/2563 BE. | |
| // Copyright © 2563 Cup. All rights reserved. | |
| // | |
| import Foundation | |
| import SwiftDate | 
  
    
      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
    
  
  
    
  | //========= FirstViewVC ========= | |
| /* | |
| import UIKit | |
| class FirstViewVC: UIViewController { | |
| @IBOutlet weak var inputMessageTextBox: UITextField! | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| } */ | |
| override func prepare(for segue: UIStoryboardSegue, sender: Any?) { | 
  
    
      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
    
  
  
    
  | Example - Implementing delegate in Swift | |
| // 1.Make a protocol | |
| // จะเขียนแยกใส่ไฟล์(.swift)หรือเขียนใน Class ที่จะเรียกใช้ delegate ก็ได้ | |
| protocol messageSenderDelegate{ | |
| func receivedMessage(message:String) | |
| } | |
| // 2.Declare delegate you want to call | |
| // สร้างตัวแปรสำหรับเก็บ class ที่เป็น delegate มารอไว้ | 
  
    
      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
    
  
  
    
  | MKCoordinateRegion theRegion = mapView.region | |
| //Zoom out | |
| theRegion.span.longitudeDelta *= 2.0 | |
| theRegion.span.latitudeDelta *= 2.0 | |
| mapView.setRegion(theRegion, animated: true) | 
  
    
      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
    
  
  
    
  | // Struct | |
| public struct MKCoordinateRegion { | |
| public var center: CLLocationCoordinate2D | |
| public var span: MKCoordinateSpan | |
| public init() | |
| public init(center: CLLocationCoordinate2D, span: MKCoordinateSpan) | |
| } | |
| // Setting region | |
| MKCoordinateRegionMake(centerCoordinate: CLLocationCoordinate2D, span: MKCoordinateSpan) | 
  
    
      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
    
  
  
    
  | //Get previous map center | |
| mapCenter = myMapView.centerCoordinate | |
| //Set new location | |
| mapCenter = mapView.convert(CGPoint.init(x: 1, y: mapView.frame.size.height/2.0), toCoordinateFrom: mapView) | |
| //Set new center | |
| mapView.setCenter(mapCenter, animated: true) | 
  
    
      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
    
  
  
    
  | //====== MapKit ====================================== | |
| // 1.Import MapKit | |
| import Mapkit | |
| // 2.Imprement MKMapViewDelegate, CLLocationManagerDelegate | |
| class ViewController: UIViewController, MKMapViewDelegate { | |
| @IBOutlet weak var mapView: MKMapView! | |
  
    
      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
    
  
  
    
  | //1.Inheritance UIPickerViewDelegate, UIPickerViewDataSource | |
| class RadioVC: UIViewController, UIPickerViewDelegate, UIPickerViewDataSource { | |
| @IBOutlet weak var pickerView: UIPickerView! | |
| //2.Create data source for picker view | |
| let pickerData = ["Tree","Cup","Goal","Blast"] | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| //3.Set delegate | 
  
    
      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
    
  
  
    
  | import AVFoundation | |
| let url = NSURL(string: "http://radiowink.wink.in.th")! as URL | |
| private var player = AVPlayer(url:url) | |
| player.play() | |
| player.pause() | 
  
    
      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
    
  
  
    
  | // import | |
| import Firebase | |
| import FirebaseDatabase | |
| import FireAuth | |
| // Data reference | |
| let referance = FIRDatabase.database().reference(fromURL: "https://...com") | |
| let referance = FIRDatabase.database().reference(fromURL: "https://...com").child("users").child(ID) | |
| let referance = FIRDatabase.database().reference(fromURL: "https://...com").child("users/KI2PEQ4W1") | 
NewerOlder