Swift

Swift

LocalNotification

원하는 시간에 맞춰 알림을 등록하고 싶을 때 사용할만한 방법. 서버가 필요하지 않은 알림은 LocalNotification으로 처리할 수 있다.Create the notification's contentlet content = UNMutableNotificationContent()content.title = "Weekly Staff Meeting"content.body = "Every Tuesday at 2pm"UNMutableNotificationContent를 생성해 title과 body에 원하는 문구를 저장한다.필요한 경우 sound나 badge도 설정할 수 있다.Specify the conditions for delivery// Configure the recurring date.var dateC..

Swift

ARC(Automatic Reference Counting) - Strong Reference Cycles for Closures

문서는 여기 ⬇️ https://docs.swift.org/swift-book/LanguageGuide/AutomaticReferenceCounting.html Strong Reference Cycles for Closures "strong reference cycle이 발생하는 경우를 설명해 주세요"라는 면접 질문을 받았을 때 앞에서 본 내용들은 당당하게 얘기하고 이건 까먹었다. 어떻게 보면 회사에서 일할 때 제일 많이 보는 구문인데! completion 핸들러에서 [weak self] in을 사용하는 이유를 이번 포스팅에서 알아본다. 클로저는 reference type이다. 우리가 클로저를 사용할 때 클로저 내부에서 self.someProperty에 접근하는 경우가 있다. 이 때 클로저에 별도의 표기..

Swift

ARC(Automatic Reference Counting) - 강한 순환 참조와 Weak, Unowned

문서는 여기 ⬇️ https://docs.swift.org/swift-book/LanguageGuide/AutomaticReferenceCounting.html 앞 포스팅에서 Strong Reference Cycle이 만들어져 메모리에서 해제되지 않고 영영 ㅁ ㅣ아가 되어버린 인스턴스가 있을 수 있다는 것을 확인했다. 그렇다면 이런 상황을 방지하려면 어떻게 해야 할까? Resolving Strong Reference Cycles Between Class Instances 애플에서는 이런 ㅁ ㅣ아들(strong reference cycle)이 생성되는 것을 방지하는 방법을 두 가지 제시한다. 1. weak references 2. unowned references weak과 unowned를 해석해 보면 ..

Swift

ARC(Automatic Reference Counting) - What is ARC?

Swift 문서를 읽어보는 시간. 이번에는 ARC와 관련된 부분을 읽어본다. 문서는 여기 ⬇️ https://docs.swift.org/swift-book/LanguageGuide/AutomaticReferenceCounting.html Automatic Reference Counting — The Swift Programming Language (Swift 5.7) Automatic Reference Counting Swift uses Automatic Reference Counting (ARC) to track and manage your app’s memory usage. In most cases, this means that memory management “just works” in Swift,..

eunjuicy
'Swift' 카테고리의 글 목록