본문 바로가기 메뉴 바로가기

Where there is a will, there's a way

프로필사진
  • 글쓰기
  • 관리
  • 태그
  • 방명록
  • RSS

Where there is a will, there's a way

검색하기 폼
  • 분류 전체보기 (49)
    • TIL (25)
    • CS (0)
    • C++ (0)
    • iOS (6)
    • Swift (18)
    • Book (0)
  • 방명록

Swift (18)
[Swift] Extensions

목차 Extension Adding Properties Adding Methods Adding Initializers Adding Subscripts Extension Extension은 이름 그대로 형식을 확장한다는 것이다. Extension으로 확장할 수 있는 대상은 Class, Structure, Enumberation, Protocol Adding Members 🆗 Overriding Members ❌ Extension 정의 extension Type { computedProperty computedTypeProperty instanceMethod typeMethod initializer subscript NestedType } extension Type: Protocol, ... { requir..

Swift 2021. 4. 20. 15:33
[Swift] Generic

목차 Generic Function Type Parameters Type Constraints (형식 제약) Speicialization (특수화) Generic Types 형식 표기 방식 익스텐션으로 제네릭 타입 확장 확장 대상 제한 Associated Types (연관 형식) Generic Function 특정 형식과 연관되지 않은 함수를 구현하는 방법을 사용할 때 Type Parameters func name(parameters) -> Type { code } : Type Parameter 함수내부에서 파라미터 형식이나 리턴형으로 사용된다. 함수바디에서 사용하는 것도 가능하다. 실제 자료형으로 대체되는 place holder이다. Type Parameter의 이름을 T 로 생성했다고 해서 T 라는 ..

Swift 2021. 3. 23. 11:55
[Swift] Error Handling

목차 Error Handling do-catch Statements Optional Try defer Statements Result Type #1 Result Type #2 Error Handling Error 종류 Compile Time Error 문법과 관련 Runtime Error 프로그램이 실행되는 동안 발생. 문법이 아니더라도 device, resource 상태에 따라서 error가 발생할 수 도 있음. Error Handling 선언 Throwing Function / Method func name(parameters) throws -> ReturnType { statement } Throwing Initializer init(parameters) throws { statement } Thr..

Swift 2021. 3. 16. 16:18
[Swift] Property

목차 Stored Property (저장 속성) Variable Stored Property (변수 저장 속성) Constant Stored Property (상수 저장 속성) Lazy Stored Properties (지연 저장 속성) Computed Property (계산된 속성) Property Observer (속성 감시자) Type Property self & super Stored Property (저장 속성) 저장 속성은 Class와 Struct에서 선언할 수 있다. 저장 속성은 인스턴스에 속한 속성이다. 인스턴스가 생성될 때마다 새로운 저장공간이 생성된다. Variable Stored Property (변수 저장 속성) var name: Type = DefalutValue Constant ..

Swift 2021. 3. 11. 00:39
[Swift] Collection - Array, Dictionary, Set

목차 Array Dictionary Set Dictionary Dictionary는 사전과 유사한 형태로 데이터를 저장한다. 저장된 요소는 정렬되지 않는다.(Unordered Collection) - 정렬의 의미가 없음. Dict에 저장되는 자료형은 모두 같아야 한다. key와 value이 쌍으로 저장되는데 key와 value의 자료형이 모두 같아야 한다. Dictionary [key: value, key: value, key: value, ...] var dict = ["A" : "Apple", "B" : "Banana"] dict = [:] // 빈 배열 Dictionary Type Dicitonary [key: value] let dict1: Dictionary let dict2: [String:I..

Swift 2021. 3. 9. 13:56
[Swift] Structures and Classes

목차 Structures and Classes Initializer Syntax Value Types vs Reference Types Nested Types Structures and Classes 지금까지는 Apple이 제공한 형식을 사용했다. 필요한 형식을 직접 만들고자 할 때 필요한 것이 구조체와 클래스다. Custom Data Type [=User Defined Type] Enumeration Structure Class Programming Paradigm 프로그래밍 언어는 언어마다 철학을 가지고 있고, 내부적인 규칙이나 구현방식에 차이가 있다. 이러한 것들을 프로그래밍 패러다임 (Programming Paradigm) 이라고 한다. 프로그래밍 언어가 다양한 만큼 프로그래밍 패러다임도 다양하다..

Swift 2021. 3. 8. 15:19
[Swift] Closure

Closure (클로저) Closures 종류 Name Closures :: Function, Nested Function Unnamed Closures :: Anonymous Function (우리가 부르게 될 Closures) Closures 선언 { (parameters) -> ReturnType/*Closure Head*/ in statements /*Closure Body*/ } // 간단한 Closure { statements } Closures 예시 let c = { print("Hello, World") } // Closure는 이름이 없는 함수인데 c라고 이름을붙인 것 c() // Hello, World let c2 = { (str: String) -> String in return "H..

Swift 2021. 3. 8. 14:07
[Swift] Enumerations (열거형)

목차 Enumerations (열거형) Raw Values (원시 값) Enumerations (열거형) Enumerations 사용하는 이유 코드의 가독성이 높아진다. 코드의 안전성이 높아진다. // #A // 나쁜 코드, 값이 변할수도 있고, 그 값이 뭔지 알기 힘듦 let left = 0 let center = 1 let right = 2 var alignment = center // #B // #A보다 가독성이 좋아졌으나, 여기에도 문자열이라 오타가 날 수 있음. // swift는 대소문자를 구분하기때문에 정해야한다. let left = "left" let center = "center" let right = "right" var alignment = center if alignment == "C..

Swift 2021. 3. 3. 00:51
이전 1 2 3 다음
이전 다음
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
  • RawValues
  • 비트연산자
  • 세자리수마다 콤마넣기
  • 오토레이아웃
  • 범위연산자
  • scope
  • optional
  • 산술연산자
  • enumerations
  • playground
  • 흐름제어구문
  • 반복문
  • continue
  • swift
  • Constants
  • variables
  • 훈련법
  • 오버플로우연산자
  • 객체지향 생활체조
  • overflow
  • labeled
  • iOS View Life Cycle
  • 결합성
  • Functions
  • datatypes
  • 구문이름표
  • 삼항연산자
  • conditional
  • 옵셔널
  • 전산구문 기초용어
more
«   2025/09   »
일 월 화 수 목 금 토
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함

Blog is powered by Tistory / Designed by Tistory

티스토리툴바