<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Properties on Kelly Dev</title><link>https://kelly-chui.github.io/tags/properties/</link><description>Recent content in Properties on Kelly Dev</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Mon, 05 Jun 2023 00:00:00 +0000</lastBuildDate><atom:link href="https://kelly-chui.github.io/tags/properties/index.xml" rel="self" type="application/rss+xml"/><item><title>The Swift Programming Language. Properties (1)</title><link>https://kelly-chui.github.io/posts/the-swift-programming-language-11-properties-1/</link><pubDate>Fri, 02 Jun 2023 00:00:00 +0000</pubDate><guid>https://kelly-chui.github.io/posts/the-swift-programming-language-11-properties-1/</guid><description>&lt;figure class="theme-image"&gt;
&lt;img
class="theme-image__image theme-image__image--light"
src="https://kelly-chui.github.io/images/assets/swift-logo-light.svg"
alt="Swift logo"
loading="lazy"
decoding="async"
&gt;
&lt;img
class="theme-image__image theme-image__image--dark"
src="https://kelly-chui.github.io/images/assets/swift-logo-dark.svg"
alt="Swift logo"
loading="lazy"
decoding="async"
&gt;
&lt;/figure&gt;
&lt;h2 id="properties"&gt;Properties&lt;/h2&gt;
&lt;p&gt;프로퍼티는 특정 클래스, 스트럭처, 열거형에 값을 연관시킨다. 저장 프로퍼티는 변수나 상수의 값을 인스턴스의 일부로 저장하고, 컴퓨티드 프로퍼티는 값을 저장하기보다는 계산한다. 컴퓨티드 프로퍼티와 다르게, 저장 프로퍼티는 열거형에서 쓸 수 없다.&lt;/p&gt;
&lt;p&gt;저장 프로퍼티와 컴퓨티드 프로퍼티는 인스턴스와 연결되는 반면, 다르게 타입 프로퍼티는 타입 그 자체에 연결된다.&lt;/p&gt;
&lt;p&gt;추가로 프로퍼티 값의 변화를 모니터링 하고, 커스텀 액션으로 반응할 수 있는 프로퍼티 옵저버를 사용할 수도 있다. 프로퍼티 옵저버는 저장 프로퍼티에서 직접 정의하여 추가할 수 있으며, 서브클래스한태 상속된다.&lt;/p&gt;</description></item><item><title>The Swift Programming Language. Properties (2)</title><link>https://kelly-chui.github.io/posts/the-swift-programming-language-12-properties-2/</link><pubDate>Fri, 02 Jun 2023 00:00:00 +0000</pubDate><guid>https://kelly-chui.github.io/posts/the-swift-programming-language-12-properties-2/</guid><description>&lt;figure class="theme-image"&gt;
&lt;img
class="theme-image__image theme-image__image--light"
src="https://kelly-chui.github.io/images/assets/swift-logo-light.svg"
alt="Swift logo"
loading="lazy"
decoding="async"
&gt;
&lt;img
class="theme-image__image theme-image__image--dark"
src="https://kelly-chui.github.io/images/assets/swift-logo-dark.svg"
alt="Swift logo"
loading="lazy"
decoding="async"
&gt;
&lt;/figure&gt;
&lt;h3 id="property-observers"&gt;Property Observers&lt;/h3&gt;
&lt;p&gt;프로퍼티 옵저버(Property Observer)는 프로퍼티 값의 변화를 관측하고 반응한다. 프로퍼티 옵저버는 새로 설정된 값이 이전의 값과 같더라도, 프로퍼티의 값이 설정 될 때 마다 반응한다.&lt;/p&gt;
&lt;p&gt;프로퍼티 옵저버는 다음의 위치들에 추가할 수 있다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;직접 정의한 저장 프로퍼티&lt;/li&gt;
&lt;li&gt;상속받은 저장 프로퍼티&lt;/li&gt;
&lt;li&gt;상속받은 컴퓨티드 프로퍼티&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;서브클래스에서 상속받은 프로퍼티를 오버라이드 하여 프로퍼티 옵저버를 추가할 수 있다. 직접 정의한 컴퓨티드 프로퍼티의 경우에는 setter를 사용하면 프로퍼티 옵저버를 사용하지 않고도 값의 변화를 관측하고 응답할 수 있다.&lt;/p&gt;</description></item><item><title>The Swift Programming Language. Properties (3)</title><link>https://kelly-chui.github.io/posts/the-swift-programming-language-13-properties-3/</link><pubDate>Mon, 05 Jun 2023 00:00:00 +0000</pubDate><guid>https://kelly-chui.github.io/posts/the-swift-programming-language-13-properties-3/</guid><description>&lt;figure class="theme-image"&gt;
&lt;img
class="theme-image__image theme-image__image--light"
src="https://kelly-chui.github.io/images/assets/swift-logo-light.svg"
alt="Swift logo"
loading="lazy"
decoding="async"
&gt;
&lt;img
class="theme-image__image theme-image__image--dark"
src="https://kelly-chui.github.io/images/assets/swift-logo-dark.svg"
alt="Swift logo"
loading="lazy"
decoding="async"
&gt;
&lt;/figure&gt;
&lt;h3 id="type-properties"&gt;Type Properties&lt;/h3&gt;
&lt;p&gt;인스턴스 프로퍼티는 특정 타입의 인스턴스에 속하는 프로퍼티이다. 새로운 인스턴스를 만들때 마다, 인스턴스는 다른 인스턴스와 구분되는 프로퍼티 집합이 생긴다.&lt;/p&gt;
&lt;p&gt;인스턴스가 아닌 타입 자체에 속하는 프로퍼티도 있다. 이러한 프로퍼티를 타입 프로퍼티라고 하며, 얼마나 많은 그 타입의 인스턴스를 생성했느냐에 관련없이 단 하나만 존재한다.&lt;/p&gt;
&lt;p&gt;타입 프로퍼티는 특정 타입의 모든 인스턴스들이 보편적으로 사용할 값을 정의할 때 유용하다. (C의 static이랑 유사하다)&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;&lt;br&gt;
타입 그 자체는 이니셜라이저가 없기 때문에, 인스턴스 프로퍼티와 다르게 타입 프로퍼티는 저장 프로퍼티일 때 반드시 디폴트 값을 줘야한다.&lt;/p&gt;</description></item></channel></rss>