๐ŸŽ iOS

    [Swift] ๋ฐ์ดํ„ฐ ํƒ€์ž…์œผ๋กœ์„œ์˜ ํ•จ์ˆ˜

    Swift๋Š” ํ•จ์ˆ˜ํ˜• ํ”„๋กœ๊ทธ๋ž˜๋ฐ ํŒจ๋Ÿฌ๋‹ค์ž„์„ ํฌํ•จํ•˜๋Š” ๋‹ค์ค‘ ํŒจ๋Ÿฌ๋‹ค์ž„ ์–ธ์–ด ์Šค์œ„ํ”„ํŠธ์˜ ํ•จ์ˆ˜๋Š” ์ผ๊ธ‰๊ฐ์ฒด์ด๋ฏ€๋กœ ๋ณ€์ˆ˜, ์ƒ์ˆ˜ ๋“ฑ์— ์ €์žฅ์ด ๊ฐ€๋Šฅํ•˜๊ณ  ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ํ†ตํ•ด ์ „๋‹ฌํ•  ์ˆ˜๋„ ์žˆ๋‹ค. ํƒ€์ž…์ด ๋‹ค๋ฅธ ํ•จ์ˆ˜๋Š” ํ• ๋‹นํ•  ์ˆ˜ ์—†๋‹ค. (๋งค๊ฐœ๋ณ€์ˆ˜ 1ํƒ€์ž…, ๋งค๊ฐœ๋ณ€์ˆ˜2ํƒ€์ž… ...) -> ๋ฐ˜ํ™˜ํƒ€์ž… func greeting(to friend: String, from me: String){ print("Hello \(friend)! I'm \(me)") } var someFunction: (String, String) -> Void = greeting(to:from:) someFunction("a","finit") // someFunction ์ž์ฒด๊ฐ€ ํ•จ์ˆ˜์ด๊ธฐ์— ํ˜ธ์ถœ ๊ฐ€๋Šฅ // Hello a! I'm finit. someFunction = ..

    [Swift] ๋งค๊ฐœ๋ณ€์ˆ˜/์ „๋‹ฌ์ธ์ž ๋ ˆ์ด๋ธ”/๊ฐ€๋ณ€ ๋งค๊ฐœ๋ณ€์ˆ˜

    ๊ธฐ๋ณธ ๋งค๊ฐœ๋ณ€์ˆ˜ ๊ธฐ๋ณธ๊ฐ’์„ ๊ฐ–๋Š” ๋งค๊ฐœ๋ณ€์ˆ˜๋Š” ๋งค๊ฐœ๋ณ€์ˆ˜ ๋ชฉ๋ก ์ค‘์— ๋’ค์ชฝ์— ์œ„์น˜ํ•˜๋Š” ๊ฒƒ์ด ์ข‹๋‹ค. func greeting(friend: String, me: String: "Finit"){ print("Hello \(friend)! I'm \(me)") } ๋งค๊ฐœ๋ณ€์ˆ˜ ๊ธฐ๋ณธ๊ฐ’์„ ๊ฐ–๋Š” ๋งค๊ฐœ๋ณ€์ˆ˜๋Š” ์ƒ๋žตํ•  ์ˆ˜ ์žˆ๋‹ค. greeting(friend: "finit") ์ „๋‹ฌ์ธ์ž ๋ ˆ์ด๋ธ” ์ „๋‹ฌ์ธ์ž ๋ ˆ์ด๋ธ”์€ ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•  ๋•Œ ๋งค๊ฐœ๋ณ€์ˆ˜์˜ ์—ญํ• ์„ ์ข€ ๋” ๋ช…ํ™•ํ•˜๊ฒŒ ํ•˜๊ฑฐ๋‚˜ ํ•จ์ˆ˜ ์‚ฌ์šฉ์ž์˜ ์ž…์žฅ์—์„œ ํ‘œํ˜„ํ•  ๋•Œ ์‚ฌ์šฉํ•œ๋‹ค. ํ•จ์ˆ˜ ๋‚ด๋ถ€์—์„œ ์ „๋‹ฌ์ธ์ž๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ ๋งค๊ฐœ๋ณ€์ˆ˜ ์ด๋ฆ„์„ ์‚ฌ์šฉํ•œ๋‹ค. func greeting(to friend: String, from me: String){ print("Hello \(friend)! I'm \(me).") } ํ•จ์ˆ˜..

    [iOS][m1] mac์— cocoapods ์„ค์น˜ํ•˜๋Š” ๋ฒ•

    ์•ฑ ๊ฐœ๋ฐœ ์ค‘ ๋‹ค์–‘ํ•œ ํšจ๊ณผ๋ฅผ ๋„ฃ๊ณ  ์‹ถ์–ด์„œ ์ฐพ๋‹ค๊ฐ€ cocoapods๋ฅผ ์•Œ๊ฒŒ๋˜์—ˆ๋Š”๋ฐ์š”! m1 mac์— cocoapods๋ฅผ ์„ค์น˜ํ•˜๋Š” ๋ฐฉ๋ฒ•์€ intel mac๊ณผ ์กฐ๊ธˆ ๋‹ฌ๋ผ์š”. ํŒ€์›์ด ๊ธฐ์กด intel ๋ฐฉ๋ฒ•์œผ๋กœ cocoapods๋ฅผ ์„ค์น˜ํ–ˆ๋Š”๋ฐ ๊ผฌ์—ฌ๋ฒ„๋ ธ๋‹ต๋‹ˆ๋‹ค. ์•„๋ฌดํŠผ m1์€ Rosetta๋ฅผ ํ†ตํ•ด ์„ค์น˜ํ•ด์•ผํ•ฉ๋‹ˆ๋‹ค. => ์ด์ œ ๋กœ์ œํƒ€ ์—†์ด ์ฝ”์ฝ”์•„ํŒŸ์ฆˆ ์„ค์น˜ ๊ฐ€๋Šฅ!!!!!! (2021.09) ์ด๊ฒŒ ๋ฌด์Šจ ๋ง์ด๋ƒ๋ฉด, ๋ฐฉ๋ฒ•์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค. (3๋‹จ๊ณ„) => ๋ฐ”๋กœ 3๋‹จ๊ณ„๋กœ ๋„˜์–ด๊ฐ€๋ฉด ๋œ๋‹ค. (2021.09) 1. Finder > terminal ๋ณต์ œํ•ด์„œ ํ„ฐ๋ฏธ๋„2 ์ƒ์„ฑ 2. ์ •๋ณด ๊ฐ€์ ธ์˜ค๊ธฐ ํด๋ฆญ ํ›„ Rosetta๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์—ด๊ธฐ ์ฒดํฌ 3. ํ„ฐ๋ฏธ๋„2 ์—ด์–ด์„œ ๋ช…๋ น์–ด ์ž…๋ ฅ ํ›„ ์„ค์น˜ sudo gem install ffi $ sudo gem ins..

    [Swift] ๊ธฐ๋ณธ ํ•จ์ˆ˜ function

    // ๋ฐ˜ํ™˜๊ฐ’ O func sum(a: Int, b: Int) -> Int { return a+b } // ๋ฐ˜ํ™˜๊ฐ’ X func printMyName(name: String) -> Void{ print(name) } // ๋งค๊ฐœ๋ณ€์ˆ˜ X func maximumIntegerValue() -> Int{ return Int.max } // ๋ฐ˜ํ™˜๊ฐ’ X ๋งค๊ฐœ๋ณ€์ˆ˜ X func hello() -> Void{ print("hello") } // ํ•จ์ˆ˜์˜ ํ˜ธ์ถœ sum(a: 3, b:5) //8

    [Swift] ์ปฌ๋ ‰์…˜ ํƒ€์ž… | Array, Dictionary, Set

    - Array: ์ˆœ์„œ๊ฐ€ ์žˆ๋Š” ๋ฆฌ์ŠคํŠธ ์ปฌ๋ ‰์…˜ var integers: Array = Array() integers.append(1) integers.append(100) //integers.append(101.1) // ์˜ค๋ฅ˜ integers.contains(100) // true integers.remove(at:0) // 0๋ฒˆ ์ธ๋ฑ์Šค์˜ ๊ฐ’ ์‚ญ์ œ integers.removeLast() integers.removeAll() integers.count // Array์™€ [Double]์€ ๋™์ผํ•œ ํ‘œํ˜„ var doubles: Array = [Double]() var strings: [String] = [String]() var characters: [Character] = [] // let์„ ์‚ฌ์šฉํ•˜์—ฌ ๋ถˆ๋ณ€ Arr..

    [Swift] Any, AnyObject, nil

    Any: Swift์˜ ๋ชจ๋“  ํƒ€์ž…์„ ์ง€์นญํ•˜๋Š” ํ‚ค์›Œ๋“œ var Anything: Any = 123 Anything = "์–ด๋–ค ํƒ€์ž…๋„ ์ˆ˜์šฉ ๊ฐ€๋Šฅ" Anything = 123.12 โ€ป ํ•˜๋‚˜์˜ ์ปฌ๋ ‰์…˜ ์•ˆ์— ์—ฌ๋Ÿฌ๊ฐ€์ง€ ๋‹ค๋ฅธ ํƒ€์ž…์˜ ๊ฐ’์„ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ• let anyCollection:[Any] = [0,"Busan",31.0] let anyDictionary: [String:Any] = ["Temp":-5.0, "Home":"Seoul", "isFemale":true] AnyObject: ๋ชจ๋“  ํด๋ž˜์Šค ํƒ€์ž…์„ ์ง€์นญํ•˜๋Š” ํ”„๋กœํ† ์ฝœ - ํด๋ž˜์Šค์˜ ์ธ์Šคํ„ด์Šค class AnyClass {} var AnyObjectThing: AnyObject = SomeClass() someAnyObject = 123.12 // ์˜ค๋ฅ˜ nil: ๊ฐ’์ด..

    [Swift] Struct์™€ Class

    ๊ตฌ์กฐ์ฒด์™€ ํด๋ž˜์Šค ๊ธฐ๋ณธ ํ˜•ํƒœ struct ๊ตฌ์กฐ์ฒด_์ด๋ฆ„{ ํ”„๋กœํผํ‹ฐ์™€ ๋ฉ”์†Œ๋“œ๋“ค } class ํด๋ž˜์Šค_์ด๋ฆ„{ ํ”„๋กœํผํ‹ฐ์™€ ๋ฉ”์†Œ๋“œ๋“ค } ๊ตฌ์กฐ์ฒด์™€ ํด๋ž˜์Šค์˜ ๊ณตํ†ต์  ์—ฌ๋Ÿฌ ๋ณ€์ˆ˜๋ฅผ ๋‹ด์„ ์ˆ˜ ์žˆ๋Š” ์ปจํ…Œ์ด๋„ˆ ๋ฐ์ดํ„ฐ๋ฅผ ์šฉ๋„์— ๋งž๊ฒŒ ๋ฌถ์–ด ํ‘œํ˜„ํ•˜๊ณ ์ž ํ• ๋•Œ ์šฉ์ด ํ”„๋กœํผํ‹ฐ์™€ ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๊ตฌ์กฐํ™”๋œ ๋ฐ์ดํ„ฐ์™€ ๊ธฐ๋Šฅ์„ ๊ฐ€์ง„๋‹ค ์ดˆ๊ธฐํ™”๋ฅผ ์ •์˜ํ•˜์—ฌ ์ดˆ๊ธฐ ์ƒํƒœ๋ฅผ ์„ค์ •ํ•  ์ˆ˜ ์žˆ๋‹ค ํ™•์žฅ(extension) ํ•  ์ˆ˜ ์žˆ๋‹ค. ํ”„๋กœํ† ์ฝœ ์‚ฌ์šฉ์ด ๊ฐ€๋Šฅํ•˜๋‹ค. ๊ตฌ์กฐ์ฒด์™€ ํด๋ž˜์Šค์˜ ์ฐจ์ด์  ๊ตฌ์กฐ์ฒด๋Š” value type, ํด๋ž˜์Šค๋Š” reference type ๊ตฌ์กฐ์ฒด๋Š” ์ƒ์†ํ•  ์ˆ˜ ์—†๋‹ค. ๊ตฌ์กฐ์ฒด๋Š” ์ƒ์„ฑ์ž๋ฅผ ๊ตฌํ˜„ํ•˜์ง€ ์•Š์„ ์‹œ ๊ธฐ๋ณธ initializer๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. ํƒ€์ž… ์บ์ŠคํŒ…์€ ํด๋ž˜์Šค์˜ ์ธ์Šคํ„ด์Šค์—๋งŒ ํ—ˆ์šฉ ๋œ๋‹ค. struct ์˜ˆ์‹œ struct CharcterData{ ..

    [ Swift ] ์—ฌ๋Ÿฌ ์ค„์˜ ๋ฌธ์ž์—ด์„ ๋งŒ๋“œ๋Š” ๋ฐฉ๋ฒ•

    ์—ฌ๋Ÿฌ ์ค„์˜ ๋ฌธ์ž์—ด์„ ๋งŒ๋“œ๋Š” ๋ฐฉ๋ฒ• : ์—ฌ๋Ÿฌ์ค„์˜ ๋ฌธ์ž์—ด์„ ์‚ฌ์šฉํ•˜๊ณ  ์‹ถ์€ ๊ฒฝ์šฐ ํฐ ๋”ฐ์˜ดํ‘œ 3๊ฐœ(“””)๋กœ ๋ฌถ์–ด์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. jusung.gitbook.io/the-swift-language-guide/language-guide/03-strings-and-characters ๋ฌธ์ž์—ด๊ณผ ๋ฌธ์ž (Strings and Characters) jusung.gitbook.io