Posted
Filed under 개발/그외
* 텍스트에디터
- 한국어, 일본어, 중국어를 모두 표시할 수 있는 폰트가 필요하다.

- 어도비와 구글이 합작하여 출시한 본고딕이라는 서체가 CJK 폰트이다.
http://blog.typekit.com/alternate/source-han-sans-kor/

- 윈도 10에서는 OpenType/CFF Collection (OTC) 형식의 폰트를 설치하면 된다. 세리프가 명조체, 산세리프가 고딕체이다.
http://www.google.com/get/noto/help/cjk/


* 코딩용 IDE
- 문자열을 스페이스단위로 일치시켜야 하므로 폰트가 고정폭(Monospaced) 이어야 한다.
- 오인식하기 쉬운 알파벳, 특수문자에 대한 대책이 있어야 한다.
- 특수문자의 가독성을 높여준다고 하는 Ligature는 필수는 아니다.
- 한글이 깨끗하게 나오면 좋지만 영문체보다 중요하진 않다

폰트는 개인 취향이 강하게 반영되기 때문에 사이트마다 추천하는 글꼴도 많이 다르지만,  
어디서든 많이 추천되는 폰트를 알파벳순으로 나열하면 다음과 같다.
개인적으로는 Inconsolata를 사용한다.
Anonymous Pro  http://www.marksimonson.com/fonts/view/anonymous-pro
Consolas  http://www.microsoft.com/en-us/download/details.aspx?id=17879
Dejavu Sans Mono  http://dejavu-fonts.github.io/
Fira Code  http://github.com/tonsky/FiraCode
Hack  http://github.com/source-foundry/Hack
Inconsolata  http://levien.com/type/myfonts/inconsolata.html
Input Mono  http://input.fontbureau.com/
Menlo  http://www.cufonfonts.com/font/menlo
Monaco  http://www.gringod.com/2006/11/01/new-version-of-monaco-font/
Source Code Pro  http://github.com/adobe-fonts/source-code-pro
Ubuntu Mono  http://design.ubuntu.com/font/

D2Coding: 네이버에서 개발한 한글, 리가쳐도 지원하는 오픈소스 폰트
http://github.com/naver/d2codingfont
Myrica: 일본어로 코딩할 때 평이 좋은 오픈소스 폰트
https://myrica.estable.jp/

특정 폰트에 대해서는 가상 터미널에서 확인해볼 수도 있다.
http://app.programmingfonts.org/

2019/05/08 15:47 2019/05/08 15:47
Posted
Filed under 개발/iOS
* How To: Working With Timers In Swift
https://learnappmaking.com/timer-swift-how-to/
- 반복타이머 설정 (@objc 필요)
[code]
let timer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(fire), userInfo: nil, repeats: true)
[/code]

- 클로저로 만들수도 있다
[code]
let timer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true, block: { timer in
    print("FIRE!!!")
})
[/code]

- userInfo를 이용해 타이머속 함수에 값을 전달할 수 있다
[code]
let timer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(fire(timer:)), userInfo: ["score": 10], repeats: true)

@objc func fire(timer: Timer)
{
    if  let userInfo = timer.userInfo as? [String: Int],
        let score = userInfo["score"] {

        print("You scored \(score) points!")
    }
}
[/code]

- 카운트다운 타이머 생성
[code]
var timer:Timer?
var timeLeft = 60
timer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(onTimerFires), userInfo: nil, repeats: true)
@objc func onTimerFires()
{
    timeLeft -= 1
    timeLabel.text = "\(timeLeft) seconds left"

    if timeLeft <= 0 {
        timer.invalidate()
        timer = nil
    }
}
[/code]

- 타이머는 run loop와 동시에 돌아간다. 런루프는 상황을 보고 타이머를 돌리는데 tolerence를 주면 타이머에 여유를 줄 수 있다. 애플은 10% 여유분을 권장한다. tolerence는 ±가 아닌 +만을 의미한다. 또한 이번 타이머가 톨러런스에 의해 늦어지더라도 다음 타이머에는 영향을 주지 않는다.
[code]
let timer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(fire), userInfo: nil, repeats: true)
timer.tolerance = 0.2
[/code]

- 타이머는 메인쓰레드의 run loop에 default mode로 등록되므로 메인쓰레드가 너무 바쁘면 실행되지 않을 수도 있다. 다음과 같이 commonModes로 등록하면 쓰레드가 타이머를 항상 감시하게 된다.
[code]
let timer = Timer(timeInterval: 1.0, target: self, selector: #selector(fire), userInfo: nil, repeats: true)
RunLoop.current.add(timer, forMode: .commonModes)
[/code]

- 타이머가 아닌 Grand Central Dispatch를 이용하여 코드에 딜레이 주기. 타이머는 계속 감시해야 하는데 GCD는 한번만 실행되므로 이쪽이 더 경제적이다.
[code]
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(300)) { 
    print("BOOYAH!")
}
[/code]

* Build a count down timer with Swift 3.0
https://medium.com/ios-os-x-development/build-an-stopwatch-with-swift-3-0-c7040818a10f
- 카운트다운 타이머를 만드는 예제
2019/05/08 10:34 2019/05/08 10:34