๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
  • Dev Blog

SWIFT3

[Swift] - ์ฝœ๋ ‰์…˜ ํƒ€์ž… (Collection Types) ์ฐธ๊ณ  ์ž๋ฃŒ ์ฝœ๋ ‰์…˜ ํƒ€์ž… (Collection Types) - Swiftlet oddDigits: Set = [1, 3, 5, 7, 9] let evenDigits: Set = [0, 2, 4, 6, 8] let singleDigitPrimeNumbers: Set = [2, 3, 5, 7] // [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]bbiguduk.gitbook.io Swift ๊ณต์‹ ๋ฌธ์„œ๋ฅผ ํ•œ๊ตญ์–ด๋กœ ๋ฒˆ์—ญํ•œ ์‚ฌ์ดํŠธ์ž…๋‹ˆ๋‹ค.๐Ÿ’ป ์ฐธ๊ณ  ์ž๋ฃŒ์˜ ๋ชจ๋“  ๋‚ด์šฉ์„ ๋‹ค๋ฃจ๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋ผ ์ƒˆ๋กญ๊ฒŒ ์•Œ๊ฒŒ ๋œ ์  ํ˜น์€ ๋‹ค๋ฅธ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด๋“ค๊ณผ ๋น„๊ตํ–ˆ์„ ๋•Œ ๋‹ค๋ฅธ ์ ๋“ค์„ ์œ„์ฃผ๋กœ ์ •๋ฆฌํ–ˆ์Šต๋‹ˆ๋‹ค. ๋˜ํ•œ, ์ฐธ๊ณ  ์ž๋ฃŒ ์ด์™ธ์—๋„ ์ถ”๊ฐ€์ ์œผ๋กœ ๊ณต๋ถ€ํ•œ ๋ถ€๋ถ„๋„ ์ •๋ฆฌํ–ˆ์Šต๋‹ˆ๋‹ค. ArrayArray๋Š” ๋ฉค๋ฒ„๊ฐ€ ์ˆœ์„œ(์ธ๋ฑ์Šค)๋ฅผ ๊ฐ€์ง„ ๋ฆฌ์ŠคํŠธ ํ˜•ํƒœ์˜.. 2024. 10. 27.
[Swift] - ๊ธฐ๋ณธ ์—ฐ์‚ฐ์ž (Basic Operators) ์ฐธ๊ณ  ์ž๋ฃŒ ๊ธฐ๋ณธ ์—ฐ์‚ฐ์ž (Basic Operators) - Swift์œ„์˜ ์˜ˆ์ œ ์ฒซ๋ฒˆ์งธ ์ค„์—์„œ ์™ผ์ชฝ์—์„œ ์˜ค๋ฅธ์ชฝ์œผ๋กœ ๋น„๊ตํ•˜๋Š” ๋™์ž‘์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ํŠœํ”Œ์˜ ๋‹ค๋ฅธ ์–ด๋–ค๊ฐ’๊ณผ ์ƒ๊ด€์—†์ด 1 ์ด 2 ๋ณด๋‹ค ์ž‘๊ธฐ ๋•Œ๋ฌธ์— (1, "zebra") ๋Š” (2, "apple") ๋ณด๋‹ค ์ž‘์Šต๋‹ˆ๋‹ค. ํŠœํ”Œ์˜ ์ฒซ๋ฒˆbbiguduk.gitbook.ioSwift ๊ณต์‹ ๋ฌธ์„œ๋ฅผ ํ•œ๊ตญ์–ด๋กœ ๋ฒˆ์—ญํ•œ ์‚ฌ์ดํŠธ์ž…๋‹ˆ๋‹ค.๐Ÿ’ป ์ฐธ๊ณ  ์ž๋ฃŒ์˜ ๋ชจ๋“  ๋‚ด์šฉ์„ ๋‹ค๋ฃจ๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋ผ ์ƒˆ๋กญ๊ฒŒ ์•Œ๊ฒŒ ๋œ ์  ํ˜น์€ ๋‹ค๋ฅธ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด๋“ค๊ณผ ๋น„๊ตํ–ˆ์„ ๋•Œ ๋‹ค๋ฅธ ์ ๋“ค์„ ์œ„์ฃผ๋กœ ์ •๋ฆฌํ–ˆ์Šต๋‹ˆ๋‹ค. ๋˜ํ•œ, ์ฐธ๊ณ  ์ž๋ฃŒ ์ด์™ธ์—๋„ ์ถ”๊ฐ€์ ์œผ๋กœ ๊ณต๋ถ€ํ•œ ๋ถ€๋ถ„๋„ ์ •๋ฆฌํ–ˆ์Šต๋‹ˆ๋‹ค.ํ• ๋‹น ์—ฐ์‚ฐ์žlet b = 10 // ์ƒ์ˆ˜var a = 5 // ๋ณ€์ˆ˜a = b * ํŠœํ”Œ์„ ์ด์šฉํ•ด์„œ ์—ฌ๋Ÿฌ ๊ฐ’์„ ํ•œ ๋ฒˆ์— ํ• ๋‹นํ•  ์ˆ˜ .. 2024. 10. 26.
[Swift] - ๋ฌธ์ž์—ด๊ณผ ๋ฌธ์ž (Strings and Characters) ์ฐธ๊ณ  ์ž๋ฃŒ ๋ฌธ์ž์—ด๊ณผ ๋ฌธ์ž (Strings and Characters) - Swift์œ„ ์˜ˆ์ œ์—์„œ ์ฒซ๋ฒˆ์งธ 3๊ฐœ์˜ codeUnit ๊ฐ’ (68, 111, 103)์€ ASCII์™€ ๊ฐ™์€ UTF-8 ํ‘œํ˜„์ธ ๋ฌธ์ž D, o, ๊ทธ๋ฆฌ๊ณ  g ๋ฅผ ๋‚˜ํƒ€๋ƒ…๋‹ˆ๋‹ค. ๋‹ค์Œ 3๊ฐœ์˜ codeUnit ๊ฐ’ (226, 128, 188)์€ DOUBLE EXCLAMATION MARK ๋ฌธ์ž์˜ 3 ๋ฐ”์ดํŠธ UTF-8 ํ‘œํ˜„์ž…๋‹ˆbbiguduk.gitbook.io Swift ๊ณต์‹ ๋ฌธ์„œ๋ฅผ ํ•œ๊ตญ์–ด๋กœ ๋ฒˆ์—ญํ•œ ์‚ฌ์ดํŠธ์ž…๋‹ˆ๋‹ค.๐Ÿ’ป ์ฐธ๊ณ  ์ž๋ฃŒ์˜ ๋ชจ๋“  ๋‚ด์šฉ์„ ๋‹ค๋ฃจ๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋ผ ์ƒˆ๋กญ๊ฒŒ ์•Œ๊ฒŒ ๋œ ์  ํ˜น์€ ๋‹ค๋ฅธ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด๋“ค๊ณผ ๋น„๊ตํ–ˆ์„ ๋•Œ ๋‹ค๋ฅธ ์ ๋“ค์„ ์œ„์ฃผ๋กœ ์ •๋ฆฌํ–ˆ์Šต๋‹ˆ๋‹ค. ๋˜ํ•œ, ์ฐธ๊ณ  ์ž๋ฃŒ ์ด์™ธ์—๋„ ์ถ”๊ฐ€์ ์œผ๋กœ ๊ณต๋ถ€ํ•œ ๋ถ€๋ถ„๋„ ์ •๋ฆฌํ–ˆ์Šต๋‹ˆ๋‹ค. multiLineString์—ฌ๋Ÿฌ ์ค„.. 2024. 10. 25.