Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- NSManagedObject SubClass
- Java
- LightWeight Migration
- 2022 부스트캠프
- 스위프트 클로저
- CoreData Stack
- 트레일링 클로저
- expensive operation
- CoreData
- persistentStoreCoordinator
- NSPredicates
- CoreData Concurrency
- Raw value and Associated value
- 일급 객체
- leetcode #01
- 1009번
- 다익스트라 이해
- Swift LinkedList
- Swift 고차함수
- CoreData Filter
- NSSortDescriptor
- iOS Static Library 사용하는방법
- iOS Static Library
- dateFormatter
- Clean swift
- Associated Value
- codability
- Swift closure
- Swift
- Persistent store Coordinator
Archives
- Today
- Total
하루를살자
Swift Basics - Playground(Xcode), Data type, Function 본문
Basic Flow of Application
reference : https://www.youtube.com/watch?v=F2ojC6TNwws
Xcode - Playground
It provides a simple tool called "playground" which enables to practice Swift. It also has advantages on as following;
- REPL - Read, Eval, Print, Loop 가능
- 프로젝트 생성 불필요
- 코드 작성/변경 - 바로 결과 확인 가능
Swift
Data-type
- String : "Hello"
- Int : 1,2,
- Double : 0.2, 1.2
- Bool : ture, false
- var : mutable variable
- let : immutable variable
- uses Camel case
Function
- Basic call
1. func functionName () {}
--> type 'func' in front of the name of the function
2. Parameters
--> Swift has various ways to assign parameters of a function, and depending on the way it is stated, it is considered as a different function even if the name of the function is duplicated with the others.
Example)
func myFunc(){
let a = 10
let b = 10
print(a+b)
}
func myFunc(a:Int , b:Int){
print(a-b)
}
func myFunc(firstNum a:Int, secondNum b:Int){
print(a*b)
}
myFunc()
myFunc(a: 10, b: 20)
myFunc(firstNum: 5, secondNum: 4)
3. return
Declare the type of return followed by '->' after parameter declaration.
func myFunc(firstNum a:Int, secondNum b:Int) -> Int{
return a*b
}
'Swift' 카테고리의 다른 글
Swift 고차함수 (0) | 2022.02.05 |
---|---|
Swift - Collection Types (0) | 2022.01.01 |
Swift - Enum (0) | 2021.12.31 |
Swift - Optionals (0) | 2021.12.21 |
SwiftUI Architecture - MVVM (Model, View, and ViewModel) (0) | 2021.12.20 |
Comments