๐Ÿ‘ฉ๐Ÿป‍๐Ÿ’ป iOSun
article thumbnail
[iOS] ์ฝ”๋“œ ๋ฒ ์ด์Šค๋กœ ํ”„๋กœ์ ํŠธ ์„ธํŒ…ํ•˜๊ธฐ
iOS 2024. 1. 21. 18:34

ํ”„๋กœ์ ํŠธ ์„ธํŒ…ํ•  ๋•Œ๋งˆ๋‹ค ์ฐพ์•„๋ด์„œ ์ด๋ฒˆ ๊ธฐํšŒ์— ์ •๋ฆฌํ•˜๋ ค ํ•œ๋‹ค. 1. Main ์Šคํ† ๋ฆฌ๋ณด๋“œ ์‚ญ์ œ 2. Project target - Build Settings - main๊ฒ€์ƒ‰ - UiKit Main Storybard File base Name ์‚ญ์ œ 3. info.plist - storybard Name ์‚ญ์ œ 4. SceneDelegate ์ˆ˜์ • func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { guard let windowScene = (scene as? UIWindowScene) else { return } window = UIWindow(..

article thumbnail
[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค 258707] ์นด์นด์˜ค ๊ฒจ์šธ ์ธํ„ด์‹ญ, n + 1 ์นด๋“œ๊ฒŒ์ž„, swift

๋ฌธ์ œ ์„ค๋ช… ๋‚œ์ด๋„: level3 ๋ฌธ์ œ ํ’€์ด ์ด ๋ฌธ์ œ์˜ ํ•ต์‹ฌ์€ ์นด๋“œ๋ฅผ ๋ผ์šด๋“œ๋งˆ๋‹ค ๋ฝ‘์„ ์ƒ๊ฐ์„ ํ•˜์ง€ ์•Š๊ณ  ํ‚ต ํ•ด๋‘๋Š” ๊ฒƒ์ด๋‹ค. keepCards๋ผ๋Š” ๋ฐฐ์—ด์„ ๋งŒ๋“ค๊ณ  ๋ผ์šด๋“œ๋งˆ๋‹ค ์นด๋“œ 2์žฅ์„ ํ‚ตํ•ด๋‘”๋‹ค. ๋‚ด๊ฐ€ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ์นด๋“œ๋Š” myCards๋ผ๋Š” ๋ฐฐ์—ด์— ์ €์žฅํ•œ๋‹ค. 1. myCards์—์„œ ํƒ€๊ฒŸ ๋„˜๋ฒ„๋ฅผ ๋งŒ๋“ ๋‹ค. (์ฝ”์ธ 0๊ฐœ ์†Œ๋ชจ) 2. 1๋ฒˆ์ด ์•ˆ๋˜๋ฉด ์ฝ”์ธ 1๊ฐœ ์ด์ƒ ์žˆ์„ ๋•Œ, myCards์—์„œ 1์žฅ + keepCards์—์„œ 1์žฅ ์จ์„œ ํƒ€๊ฒŸ ๋„˜๋ฒ„๋ฅผ ๋งŒ๋“ ๋‹ค. (์ฝ”์ธ 1๊ฐœ ์†Œ๋ชจ) 3. 2๋ฒˆ์ด ์•ˆ๋˜๋ฉด ์ฝ”์ธ 2๊ฐœ ์ด์ƒ ์žˆ์„ ๋•Œ, keepCards์—์„œ 2์žฅ์„ ์จ์„œ ํƒ€๊ฒŸ ๋„˜๋ฒ„๋ฅผ ๋งŒ๋“ ๋‹ค. (์ฝ”์ธ 2๊ฐœ ์†Œ๋ชจ) ๋งŒ์•ฝ 1,2,3์—์„œ ํƒ€๊ฒŸ ๋„˜๋ฒ„๋ฅผ ๋ชป์ฐพ๋Š”๋‹ค๋ฉด ๋ผ์šด๋“œ ์ข…๋ฃŒ ์ฝ”์ธ๋„ ์—†๊ณ  ๋‚จ์•„์žˆ๋Š” ์นด๋“œ๋„ ์—†๋‹ค๋ฉด ์ข…๋ฃŒ ์˜ˆ์ œ๋กœ ์„ค๋ช…ํ•˜์ž๋ฉด ์ฝ”์ธ = 4๊ฐœ..

article thumbnail
[swift] ์ƒ์†, ์˜ค๋ฒ„๋ผ์ด๋”ฉ
Swift 2024. 1. 6. 00:58

์ƒ์† ์ƒ์†์ด๋ž€? ์ƒ์†์€ ์˜ค์ง ํด๋ž˜์Šค์—์„œ๋งŒ ๊ฐ€๋Šฅํ•˜๋ฉฐ ๋ถ€๋ชจ์˜ ๋ฉ”์†Œ๋“œ์™€ ํ”„๋กœํผํ‹ฐ์™€ ๊ฐ™์€ ํŠน์„ฑ๋“ค์„ ๊ทธ๋Œ€๋กœ ๋ฌผ๋ ค๋ฐ›๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์ƒ์†์„ ์™œ ์‚ฌ์šฉํ• ๊นŒ? ์ƒ์†์€ ๋ถ€๋ชจ์˜ ํŠน์„ฑ์„ ๊ทธ๋Œ€๋กœ ๋ฌผ๋ ค๋ฐ›์„ ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ์ค‘๋ณต๋œ ์ฝ”๋“œ ์ž‘์„ฑ์„ ์ค„์ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ex) ์ธ๊ฐ„์€ ๊ณ ์œ ์˜ ์ด๋ฆ„, ์„ฑ๋ณ„์ด ์žˆ์Šต๋‹ˆ๋‹ค. ๋งŒ์•ฝ A, B, C๋ผ๋Š” ์ธ๊ฐ„์ด ์žˆ๊ณ  ๊ฐ๊ฐ ์ธ๊ฐ„๋“ค์€ ๊ณ ์œ ์˜ ํŠน์„ฑ์„ ๊ฐ€์ง€๊ณ  ์žˆ์ง€๋งŒ ๊ณตํ†ต์ ์œผ๋กœ ๋ชจ๋‘ ์ด๋ฆ„๊ณผ ์„ฑ๋ณ„์„ ๊ฐ€์ง€๊ณ  ์žˆ๊ฒ ์ฃ ? ์ƒ์†์„ ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š”๋‹ค๋ฉด? → A, B, C ๋ชจ๋‘ ํ•˜๋‚˜ํ•˜๋‚˜ ์ด๋ฆ„, ์„ฑ๋ณ„์„ ๋„ฃ์–ด์ฃผ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์ƒ์†์„ ์‚ฌ์šฉํ•œ๋‹ค๋ฉด? → ์ธ๊ฐ„์ด๋ผ๋Š” ํด๋ž˜์Šค ํ•˜๋‚˜๋ฅผ ๋งŒ๋“ค๊ณ  A, B, C๋Š” ์ธ๊ฐ„ ํด๋ž˜์Šค๋ฅผ ์ƒ์†๋งŒ ํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค. ์ƒ์† ์ฝ”๋“œ class Human { var name: String? var gender: String? } ..

article thumbnail
[swift] ๋ฉ”์†Œ๋“œ
Swift 2023. 12. 29. 22:27

ํ•จ์ˆ˜ vs ๋ฉ”์†Œ๋“œ ๋ญ” ์ฐจ์ด? func ํ‚ค์›Œ๋“œ ๋ถ™์€ ๊ฑด ๋‹ค ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค. ๋ฉ”์†Œ๋“œ๋Š” ํด๋ž˜์Šค, ๊ตฌ์กฐ์ฒด, ์—ด๊ฑฐํ˜•์— ์†ํ•œ ํ•จ์ˆ˜๋ฅผ ๋œปํ•ฉ๋‹ˆ๋‹ค. (์ฆ‰, ํ•จ์ˆ˜๊ฐ€ ๋” ํฐ ๊ฐœ๋…) swift์—์„œ ๋ฉ”์†Œ๋“œ๋Š” ํฌ๊ฒŒ ๋‘๊ฐ€์ง€๋กœ ๋‚˜๋‰ฉ๋‹ˆ๋‹ค. ์ธ์Šคํ„ด์Šค ๋ฉ”์†Œ๋“œ ํƒ€์ž… ๋ฉ”์†Œ๋“œ ๋‘˜์˜ ํฐ ์ฐจ์ด์ ์€ ์ธ์Šคํ„ด์Šค๋ฅผ ์ƒ์„ฑํ•ด์•ผ ํ•˜๋ƒ ์•ˆํ•˜๋ƒ์ž…๋‹ˆ๋‹ค. ์ธ์Šคํ„ด์Šค ๋ฉ”์†Œ๋“œ class Counter { var count = 0 func increment() { count += 1 } } let counter = Counter() // ์ธ์Šคํ„ด์Šค๋ฅผ ์ƒ์„ฑํ•˜๊ณ  counter.increment() // ๋ฉ”์†Œ๋“œ๋ฅผ ์‹คํ–‰ํ•œ๋‹ค. ์ธ์Šคํ„ด์Šค๋ฅผ ์ƒ์„ฑํ•˜๊ณ  ํ•ด๋‹น ์ธ์Šคํ„ด์Šค์—์„œ ๋ฉ”์†Œ๋“œ๋ฅผ ํ˜ธ์ถœํ•ฉ๋‹ˆ๋‹ค. ํƒ€์ž… ๋ฉ”์†Œ๋“œ class People { class func sayBye() { // 1. ํด๋ž˜์Šค ๋ฉ”์†Œ๋“œ..

profile on loading

Loading...