Skip to content

Instantly share code, notes, and snippets.

View jinios's full-sized avatar
🌏
iOS developer

MIJIN JEON jinios

🌏
iOS developer
View GitHub Profile
//
// main.swift
// MetaType_Example
//
// Created by moon on 2018. 6. 22..
// Copyright © 2018년 moon. All rights reserved.
//
import Foundation
class ReadValue {
private var thread : Thread? = nil
init(with handler: @escaping (String) -> ()) {
thread = Thread(block: {
while(true) {
let value = readLine() ?? ""
handler(value)
}
})
thread?.start()
@godrm
godrm / swift_api_guideline.md
Last active March 27, 2024 05:15
스위프트 API 가이드라인

1. 스타일/문법 리뷰

1-1 스위프트 API 디자인 가이드라인

https://swift.org/documentation/api-design-guidelines/

  • 사용할 때 기준으로 명확하게 작성하는 게 가장 중요한 지향점이다. 메소드나 프로퍼티 같은 개발 요소는 한 번만 선언하고 반복적으로 사용한다. API를 만들 때는 사용하기 명확하고 편하게 만들어야 한다. 설계를 검증할 때 선언 부분을 읽는 것만으로는 부족하다. 그 대신 사용하는 상황에서 맥락에 맞고 명확한 지 늘 고려해야 한다.

  • 명확한 표현이 압축한 간결성보다 더 중요하다. 스위프트 코드는 압축해서 간결하게 작성할 수 있지만, 단지 글자수를 줄여서 가장 짧은 코드를 만드는 게 목표는 아니다. 스위프트 코드의 간결성은 자연스럽게 반복적으로 재사용하는 코드(boilerplate)를 줄이는 기능과 강한 타입 시스템의 부수효과로 드러날 뿐이다.

@sgr-ksmt
sgr-ksmt / Contents.swift
Last active May 9, 2022 23:07
JSONDecoder+keypath
//: Playground - noun: a place where people can play
import UIKit
var json: String = """
{
"result": {
"persons": [
{