210604 Fri

Sunny·2021년 7월 3일
0

Today I Learned

목록 보기
70/88

학습 내용: lazy var

A lazy stored property is a property whose initial value isn’t calculated until the first time it’s used.

Lazy properties are useful

  1. when the initial value for a property is dependent on outside factors whose values aren’t known until after an instance’s initialization is complete.
  2. when the initial value for a property requires complex or computationally expensive setup that shouldn’t be performed unless or until it’s needed.
  • 예제 코드

    class DataImporter {
        /*
        DataImporter is a class to import data from an external file.
        The class is assumed to take a nontrivial amount of time to initialize.
        */
        var filename = "data.txt"
        // the DataImporter class would provide data importing functionality here
    }
    
    class DataManager {
        lazy var importer = DataImporter()
        var data = [String]()
        // the DataManager class would provide data management functionality here
    }
    
    let manager = DataManager()
    manager.data.append("Some data")
    manager.data.append("Some more data")
    // the DataImporter instance for the importer property hasn't yet been created
    
    print(manager.importer.filename)
    // the DataImporter instance for the importer property has now been created
    // Prints "data.txt"

문제점/고민한점 → 해결방안

  • 베스트는 컬렉션뷰 하나를 쓰고 셀을 바꾸는 방법 (??)
  • 컬렉션뷰 리스트 만드는 방법

방법 모르겠고

일단 컬렉션뷰부터 공부하는 걸로...⭐️

스티븐 숙제 to Sunny, @Kio

취준생을 위한 아이폰 앱개발 콜렉션뷰 콤포지셔널 레이아웃 fundamental Tutorial (2020) ios collectionView compositional layout

profile
iOS Developer

0개의 댓글