Coder Social home page Coder Social logo

ios-study's Introduction

header

๐Ÿ‘‹ Hi there, I'm Jinuk

Gmail Badge Linkedin Badge

  • ๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป I'majored in Software at Sangmyung University
  • ๐ŸŒฑ I'm currently learning SwfitUI
  • ๐Ÿ”ญ I'm interested in iOS, Flutter

๐Ÿ’ป Experiences

  • [Organizer] AsyncSwift (2023.05 ~ )
  • [Organizer] Let'Swift (2023.03 ~ )
  • [Lead] Google Developer Student Clubs GDSC Sangmyung (2021.08 ~ 2022.07)

๐Ÿ’ช Skills

โš™๏ธ Platforms & Languages โš™๏ธ

โš’๏ธ Tools โš’๏ธ

ios-study's People

Contributors

jjinuk avatar

Watchers

 avatar

ios-study's Issues

ObservedObject๋ž€?

ObservedObject?

  • observable ๊ฐ์ฒด๋ฅผ ๊ตฌ๋…ํ•˜๋Š” property wrapper
    • observavle ๊ฐ์ฒด๊ฐ€ ๋ณ€๊ฒฝ๋˜๋ฉด ๋ทฐ์— ์—…๋ฐ์ดํŠธ ์‹œ์ผœ์ฃผ๋Š” ๊ธฐ๋Šฅ

@ObservedObject ์‚ฌ์šฉ ๋ฐฉ๋ฒ•

  • ObservableObject๋ฅผ ์ค€์ˆ˜ํ•˜๋Š” ๋ชจ๋ธ์„ ๋งŒ๋“ค๊ณ , ๊ทธ ๋ชจ๋ธ์—์„œ ๊ฐ’์ด ๋ณ€๊ฒฝ๋˜๋ฉด ๋ทฐ์— ๋ฐ˜์˜ํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉ
  • ObservavleObject๋ฅผ ์ค€์ˆ˜ํ•˜๋Š” ์ธ์Šคํ„ด์Šค๋ฅผ ์ฐธ์กฐํ•˜๊ธฐ ์œ„ํ•ด @ObservedObject๋กœ ์„ ์–ธํ•˜์—ฌ ์ฐธ์กฐ

ex) @ObservedObject ์‚ฌ์šฉํ•˜์—ฌ MVVM ํŒจํ„ด ๋งŒ๋“ค๊ธฐ

  • ๋ชจ๋ธ ์ •์˜(ObservableObject๋ฅผ ์ค€์ˆ˜)
    • ObservableObject๋Š” class ํ˜•ํƒœ๋งŒ ๊ฐ€๋Šฅ(struct๊ฐ€ ์•„๋‹˜)
final class MyViewModel: ObservableObject {
  @Published var isOn = false
  
  func toggle() {
    isOn.toggle()
  }
}

๐Ÿ”ผ์œ„ ๋ชจ๋ธ์˜ ์ธ์Šคํ„ด์Šค๋ฅผ @ObservedObject๋กœ ์ฐธ์กฐ

struct ContentView: View {
  @ObservedObject var viewModel1 = MyViewModel()
  
  var body: some View {
    VStack {
      Button(viewModel1.isOn ? "on" : "off") {
        viewModel1.toggle()
      }
    }
  }
}

์ฐธ๊ณ : https://ios-development.tistory.com/1160
https://developer.apple.com/documentation/swiftui/observedobject

ํด๋กœ์ €(Closure)?

ํด๋กœ์ €(Closure)๋ž€?

์ฝ”๋“œ์—์„œ ์ „๋‹ฌ๋˜๊ณ  ์‚ฌ์šฉ๋  ์ˆ˜ ์žˆ๋Š” ์ž์ฒด์ ์ธ(self - contained)ํ•จ์ˆ˜ ๋ธ”๋ก

  • ๋žŒ๋‹ค ํ•จ์ˆ˜์™€ ์œ ์‚ฌ
  • ํด๋ž˜์Šค์™€ ๋™์ผํ•œ ์ฐธ์กฐ ํƒ€์ž…

๊ธฐ์กด ํ•จ์ˆ˜์™€ ํด๋กœ์ € ํ•จ์ˆ˜ ๋น„๊ต

func aFunction(str: String) -> String {
    return "Hello, \(str)"
}
let _ = {(str: String) -> String in
    return "Hello, \(str)"
}

ํด๋กœ์ € ํ•จ์ˆ˜ ํ˜•ํƒœ

{ (๋งค๊ฐœ๋ณ€์ˆ˜ ๋ชฉ๋ก) -> ๋ฐ˜ํ™˜ ํƒ€์ž… in
    ์‹คํ–‰ ์ฝ”๋“œ
}

ex) a์™€ b๋ฅผ ๋”ํ•˜๋Š” ํ•จ์ˆ˜

let _ = {(a: Int, b: Int) -> Int in
    let result = a + b
     return result
}

ํด๋กœ์ €(Closure) ์ƒ๋žต

  1. ๋ฐ˜ํ™˜, ์ธ์ž ํƒ€์ž… ์ƒ๋žต

ํƒ€์ž…์„ ์•„๋Š” ๊ฒฝ์šฐ ํƒ€์ž… ์ƒ๋žต ๊ฐ€๋Šฅ

let closure1 = {a, b in 
	  let result = a + b
		return result 
}
  1. ๋ฐ˜ํ™˜ ํ‚ค์›Œ๋“œ ์ƒ๋žต

๋‹จ์ผ ํ‘œํ˜„ ํด๋กœ์ €๋Š” ๋ฐ˜ํ™˜ ํ‚ค์›Œ๋“œ ์ƒ๋žต ๊ฐ€๋Šฅ

let closure2: (Int, Int) -> Int = { a, b in
    a + b
}
  1. ์ธ์ž ์ด๋ฆ„ ์ถ•์•ฝ (Shorthand Arguments Names)

ํด๋กœ์ €์˜ ๋งค๊ฐœ๋ณ€์ˆ˜ ์ด๋ฆ„์ด ๊ตณ์ด ํ•„์š” ์—†๋‹ค๋ฉด ๋‹จ์ถ• ์ธ์ž๋ฅผ ํ™œ์šฉ ๊ฐ€๋Šฅํ•˜๋‹ค.

let closure3: (Int, Int) -> Int = { $0 + $1 }
  1. ์—ฐ์‚ฐ์ž ๋ฉ”์†Œ๋“œ(Operator Methods)
let closure4: (Int, Int) -> Int = (+)

No Assistant Results ์˜ค๋ฅ˜

์–ด์‹œ์Šคํ„ดํŠธ๊ฐ€ ์•ˆ ๋‚˜์˜ฌ๋•Œ ์–ด๋–ป๊ฒŒ ํ•ด์•ผ ํ• ๊นŒ??

  1. opt๋ˆ„๋ฅธ ์ฑ„ ์Šคํ† ๋ฆฌ๋ณด๋“œ์—์„œ ์–ด์‹œ์Šคํ„ดํŠธ๋ฅผ ๋ณด๊ณ  ์‹ถ์€ ์ปจํŠธ๋กค๋Ÿฌ ํด๋ฆญํ•˜๊ธฐ
  2. Clear Derived Data
    ํ„ฐ๋ฏธ๋„ -> rm -rf ~/Library/Developer/Xcode/DerivedData

์ด๋ž˜๋„ ์•ˆ๋‚˜์˜จ๋‹ค??
๊ทธ๋ƒฅ ์ข…๋ฃŒํ•˜์ž^^

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.