์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
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 |
- components
- ์๊ณ ๋ฆฌ์ฆ
- Decodable
- ExpressJS
- SWiFT
- nodejs
- Reduce
- ํ๋ก๊ทธ๋๋จธ์ค
- ์ฑ๋์์ธ
- mongoose
- ์ฑ๋ง๋ค๊ธฐ
- Filter
- Mac
- ios
- String.Index
- UIRefreshController
- CRUD
- DispatchQueue
- Firestore
- Cloud Firestore
- RxSwift
- Figma
- Firestore CRUD
- AVAudioPlayer
- Codable
- map
- MongoDB
- Core Data
- ์ง๋ฒ๋ณํ
- Encodable
- Today
- Total
Focus On Develop ๐ค๐ค
[Swift] ์๊ณ ๋ฆฌ์ฆ ์ฝ๋ฉ์ ์ ์ฉํ Tip๋ค! ๋ณธ๋ฌธ
[Swift] ์๊ณ ๋ฆฌ์ฆ ์ฝ๋ฉ์ ์ ์ฉํ Tip๋ค!
๋๋ฆฌ๋ฌ์ดํ 2021. 1. 5. 17:32์ด ํ์ด์ง๋ ์๊ณ ๋ฆฌ์ฆ ๋ฌธ์ ๋ฅผ ํ๋ ์์ฃผ(?) ์ฐ์ด๋ ์คํฌ(?) ๊ฐ์ ๊ฒ๋ค์ ๊ฐ๋ตํ๊ฒ ์ ๋ฆฌํด๋ ์์ ์ ๋๋ค.
์๋ฅผ ๋ค์ด์ ์..? root๊ฐ ์ด๋ป๊ฒ ๊ตฌํ์ง.. ์ง๋ฒ๋ณํ ์ด๋ป๊ฒ ํ์ง.. ๋ฑ๋ฑ! (๋งค๋ฒ ๊ตฌ๊ธ๋งํ๊ธฐ ๋ ๊ท์ฐฎ..๐) ์ ~๋ง ๊ฐ๋จํ๊ฒ ์ฌ์ฉ๋ฒ๋ง ์ ๋ฆฌํ ์์ ์ด๋๋๋ค ๐
๋ฌธ์ ํ๋ฉด์ ๋ ์์ฃผ ๋ณด์ด๋ ๊ฒ์ ์ด ํ์ด์ง์ ์ถ๊ฐํด๋๊ฐ ์์ ์ ๋๋ค ๐๐
- ๋ฐฐ์ด ์ด๊ธฐ๊ฐ ๋ฃ์ด์ ๋ง๋ค๊ธฐ
var array = Array(1...5) // [1,2,3,4,5]
- ํฌ๊ธฐ๊ฐ ์ ํด์ง ๋ฐฐ์ด ๋ง๋ค๊ธฐ
var arr = Array(repeating: 0, count: 3) // [0,0,0]
- 2์ฐจ์ ๋ฐฐ์ด ๋ง๋ค๊ธฐ
let array: [[Int]] = Array(repeating:Array(repeating:1, count: 4), count: 4) // ์์ชฝ count๊ฐ ํ, ๋ฐ๊นฅ count๊ฐ ์ด
map, filter, reduce ์์ธํ ๋ณด๊ธฐ ๐ 2020/12/15 - [iOS [Swift]/๊ธฐ์ด๋ฅผ ํํํ!] - [Swift] map, filter, reduce
- map
var string = ["1","2","3","4"]
string.map { Int($0)! } // [1,2,3,4] ๊ฐ ์์๋ฅผ ์ ๋ถ Int๋ก ๋งตํ (๋ฐ๋๋ก Int -> String๋ ๊ฐ๋ฅ)
- filter
var array = [1,2,3,4]
array.filter { $0 % 2 == 0 } // [2,4] ์กฐ๊ฑด์ ๋ง๋ ์๋ง ๋ฝ์๋
- reduce
var array = [1,2,3,4]
array.reduce(0, +) // ์ซ์ ํฉ์ด ๋ํ๋จ. ๋ฌธ์์ด ํฉ์น๊ธฐ๋ ๊ฐ๋ฅ
- ๊ฑฐ๋ญ์ ๊ณฑ
pow(2, 3) // 8. pow(๋ฐ, ์ง์), ๋ฐ์ Decimal Type
- Decimal -> Int
(decimal as NSDecimalNumber).intValue
- Root
let num: Double = 25
sqrt(num) // 5. Double ํ์
์ด ๋ค์ด๊ฐ์ผํจ
- ์ง๋ฒ ๋ณํ / ์์ธํ ๋ณด๊ธฐ ๐ 2020/12/16 - [iOS [Swift]/๊ธฐ์ด๋ฅผ ํํํ!] - [Swift] String Radix๋ฅผ ํตํ ์ง๋ฒ๋ณํ
// 10์ง์ -> N์ง๋ฒ
String(integer, radix: n)
let binary = "111"
let decimal = Int(binary, radix: 2)! // 7
// N์ง๋ฒ -> 10์ง์
Int("110101", radix: n)!
let decimal = 7
let binary = String(decimal, radix: 2) // "111"
- ๋ฌธ์ ASCII์ฝ๋
Character("a").asciiValue! // 97
- ์ ๋๊ฐ
abs(-5) // 5
- for๋ฌธ ํน์ ์ฃผ๊ธฐ๋ก ๋ฐ๋ณต
stride(from:1, to:5, by:2) // open range..5 ๋ถํฌํจ 1,3 ๊น์ง๋ง
stride(from:1, through:5, by:2) // closed range..5 ํฌํจ 1,3,5๊น์ง
ex)
for even in stride(from:2, through:100, by:2) // ์ง์๋ง
- String์ ๊ณ์ฐ์์ ๋ฐ๋ก ๊ณ์ฐ
let mathExpression = NSExpression(format: "3+4+2-1*6")
let mathValue = mathExpression.expressionValue(with: nil, context: nil) as! Int // result : 3
์ฐธ๊ณ : Emily๋ blog
'iOS [Swift] > ๊ธฐ์ด๋ฅผ ํํํ!' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Swift] strong, weak, unowned (0) | 2021.01.29 |
---|---|
[Swift] ARC (Automatic Reference Counting) (0) | 2021.01.29 |
[Swift] Core Data(2) ์ค์ตํด๋ณด๊ธฐ (0) | 2020.12.21 |
[Swift] Core Data(1) ๊ฐ๋ ์ ๋ฆฌ (0) | 2020.12.21 |
[Swift] String.components (0) | 2020.12.18 |