Programming/Swift (68) 썸네일형 리스트형 round number to 2 decimal places let currentRatio = Double (rxCurrentTextField.text!)! / Double (txCurrentTextField.text!)! railRatioLabelField.text! = String(format: "%.2f", currentRatio) Round up double to 2 decimal places How do I round up currentRatio to two decimal places? let currentRatio = Double (rxCurrentTextField.text!)! / Double (txCurrentTextField.text!)! railRatioLabelField.text! = "\(currentRatio)" stackoverflow.com make a countdown with NSTimer? @IBOutlet var countDownLabel: UILabel! var count = 10 override func viewDidLoad() { super.viewDidLoad() var timer = Timer.scheduledTimer(timeInterval: 0.4, target: self, selector: #selector(UIMenuController.update), userInfo: nil, repeats: true) } func update() { if(count > 0) { countDownLabel.text = String(count--) } } How can I make a countdown with NSTimer? How can I make a countdown with an .. Immutable value X is never used consider replacing with '_' In several cases of my old code I am getting the warning: Immutable value X is never used consider replacing with '_' For instance this often occurs if I am checking an enum which has an associated object (but I don't use the object in this case) - or if I am using the 'If let' construct to check if an object is nil or not. A. These changes are recommended because if you don't use these variable.. iOS: Tracking Visited Locations Introduction iOS has very powerful APIs for tracking user locations and working with maps. You might be making an app for your local café and want to notify the user of special offers when they are nearby. Or, you’re making a music player and you want to start playing some bouncy beats when the user enters a gym. Tracking location all the time, however, can drain a battery really fast! In this C.. Article: Choosing the Location Services Authorization to Request Determine the authorization your app needs to access location data. Overview The authorization status that your app has determines if and when it receives location events. There are two types of authorization your app can request: When In Use Your app can use all location services and receive events while the app is in use. In general, iOS apps are considered in use when they're in the foregroun.. Class: AVAudioPlayer An object that plays audio data from a file or buffer. Declaration class AVAudioPlayer : NSObject Overview Use an audio player to: Play audio of any duration from a file or buffer Control the volume, panning, rate, and looping behavior of the played audio Access playback-level metering data Play multiple sounds simultaneously by synchronizing the playback of multiple players For more information.. Class: UIViewController An object that manages a view hierarchy for your UIKit app. Declaration class UIViewController : UIResponder Overview The UIViewController class defines the shared behavior that is common to all view controllers. You rarely create instances of the UIViewController class directly. Instead, you subclass UIViewController and add the methods and properties needed to manage the view controller's view.. MVVM Design Pattern Model-View-ViewModel (MVVM) is a structural design pattern that separates objects into three distinct groups: Models hold application data. They’re usually structs or simple classes. Views display visual elements and controls on the screen. They’re typically subclasses of UIView. View models transform model information into values that can be displayed on a view. They’re usually classes, so they.. [yagom] Swift - 클로저 고급 yagom's Swift Basic 야곰의 스위프트 기본 문법 강좌 목차 강좌소개 이름짓기, 콘솔로그, 문자열 보간법 상수와 변수 기본 데이터 타입 Any, AnyObject, nil 컬렉션 타입 함수 기본 함수 고급 조건문 반복문 옵셔널 구조체 클래스 열거형 값 타입과 참조 타입 클로저 프로퍼티 상속 인스턴스의 생성과 소멸 옵셔널 체이닝과 nil 병합 연산자 타입캐스팅 assert와 guard 프로토콜 익스텐션 오류처리 고차함수 더 알아보기 yagom.github.io/swift_basic/ Swift 기본문법 야곰의 스위프트 기본 문법 강좌입니다. yagom.github.io 이전 1 2 3 4 5 ··· 7 다음