Giter Club home page Giter Club logo

beerlist's Introduction

BeerList

Simulator Screen Recording - iPod touch (7th generation) - 2023-01-31 at 23 40 47

๐Ÿงฉ ๊ฐœ์š”

  • URLSession์œผ๋กœ ๋ฐ›์•„์˜จ data๋ฅผ UITableView๋กœ ํ‘œ์‹œ
  • ๋ฐ›์•„์˜ฌ ๋ฐ์ดํ„ฐ๋ฅผ Prefetchํ•˜์—ฌ ์ตœ์ ํ™”
  • .insetGrouped ์Šคํƒ€์ผ์˜ UITableView๋ฅผ ํ‘œ์‹œ

๐Ÿค” ๋ฐฐ์šด ๋‚ด์šฉ

โœ”๏ธ UITableViewDataSourcePrefetching

์ •์˜:

์ž ์žฌ์ ์œผ๋กœ ์˜ค๋ž˜ ์‹คํ–‰๋˜๋Š” ๋ฐ์ดํ„ฐ ์ž‘์—…์„ ์กฐ๊ธฐ์— ์‹œ์ž‘ํ•  ์ˆ˜ ์žˆ๋„๋ก ๋ฏธ๋ฆฌ ์ •๋ณด๋ฅผ ์ œ๊ณตํ•˜๋Š” ํ”„๋กœํ† ์ฝœ

์ฃผ์˜์‚ฌํ•ญ:

tableView(_:cellForRowAt:) ๋ฉ”์„œ๋“œ๊ฐ€ ์‹คํ–‰๋˜๊ธฐ ์ „์— prefetch๊ฐ€ ๋น„๋™๊ธฐ์ ์œผ๋กœ ์‹คํ–‰๋œ๋‹ค.

๋”ฐ๋ผ์„œ, ํ•ด๋‹น ํ”„๋กœํ† ์ฝœ ๊ตฌํ˜„์‹œ ๋ฐ˜๋“œ์‹œ tableView(_:cellForRowAt:) ๋ฉ”์„œ๋“œ๋ฅผ ๊ตฌํ˜„ํ•˜์—ฌ์•ผ ํ•œ๋‹ค.

extension BeerListViewController: UITableViewDataSourcePrefetching {
    func tableView(_ tableView: UITableView, prefetchRowsAt indexPaths: [IndexPath]) {
        // ํ˜„์žฌํŽ˜์ด์ง€๊ฐ€ 2์ด์ƒ์ผ๋•Œ๋ถ€ํ„ฐ 
        guard currentPage != 1 else { return }
        // prefetch๋ฅผ ์‹คํ–‰
        indexPaths.forEach {
            if ($0.row + 1)/25 + 1 == currentPage {
                self.fetchBeer(of: currentPage)
            }
        }
    }
}

โœ”๏ธ ํ•ด์‰ฌํƒœ๊ทธ ๋ณ€ํ™˜ ํ•จ์ˆ˜

์˜ˆ๋ฅผ๋“ค์–ด first, second, third ๋ฌธ์ž์—ด์„ #first #second #third๋กœ ๋ณ€ํ™˜.

  let tags = taglineString?.components(separatedBy: ". ")
  let hashtags = tags?.map { "#" + $0.replacingOccurrences(of: " ", with: "")
      .replacingOccurrences(of: ".", with: "")
      .replacingOccurrences(of: ",", with: " #")
  }
  return hashtags?.joined(separator: " ") ?? ""

โœ”๏ธ imageLiteral๋กœ ์ด๋ฏธ์ง€ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ

#imageLiteral(resource:) ์ฝ”๋“œ๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ์•„๋ž˜์™€ ๊ฐ™์ด ์ด๋ฏธ์ง€๋ฅผ ์„ ํƒํ•  ์ˆ˜ ์žˆ๋Š” ํŒ์—…์ด ๋‚˜ํƒ€๋‚œ๋‹ค.

Other

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.