Taehyeon-Kim / SeSAC

☀️ SeSAC Daily Reporting
27 stars 0 forks source link

[221018] TIL #137

Open Taehyeon-Kim opened 1 year ago

Taehyeon-Kim commented 1 year ago

UICollectionView

CollectionView APIs(13+)

14+(13을 기반으로 쉽게 사용할 수 있는 기능 업데이트)

스크린샷 2022-10-18 오전 9 35 42

iOS13

SwiftUI

UIListContentConfiguration(14+)

스크린샷 2022-10-18 오전 10 08 25

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = UITableViewCell()

    var content = cell.defaultContentConfiguration()
    content.image = UIImage(systemName: "heart.fill")
    content.text = burgers[indexPath.row]
    content.secondaryText = "Detail"
    cell.contentConfiguration = content

    return cell
}
Taehyeon-Kim commented 1 year ago

UICollectionView.Registration

struct CellRegistration<Cell, Item> where Cell : UICollectionViewCell
Taehyeon-Kim commented 1 year ago
Taehyeon-Kim commented 1 year ago

타입으로서의 프로토콜: 프로토콜을 이용한 타입 대응

// Super class
class Food {

}

// Protocol
protocol Fruit {
    var price: Int { get }
}

extension Fruit {
    var price: Int {
        return 100
    }
}

class Apple: Fruit {
    func printSelf() {
        print("Apple")
    }
}

class Banana: Fruit {

}

enum Melon: Fruit {

}

struct Watermelon: Fruit {

}
var fruit: Fruit = Banana()
fruit = Apple()
// fruit = Melon()
print(fruit.price)
print((fruit as! Apple).printSelf())
return cell
tableView.delegate = self
tableView.dataSource = self