Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[220804] TIL #91

Closed
Taehyeon-Kim opened this issue Aug 4, 2022 · 2 comments
Closed

[220804] TIL #91

Taehyeon-Kim opened this issue Aug 4, 2022 · 2 comments
Assignees

Comments

@Taehyeon-Kim
Copy link
Owner

Taehyeon-Kim commented Aug 4, 2022

서버 통신 시 셀에 보여줄 UIImage 변환 시점

urlString ▶️ url ▶️ image

url로 바꾸고 또는 image로 바꾸는 과정을 어디에서 진행하는 것이 좋을까?

  1. 서버 통신 시점에서 할지 => 시간이 오래걸리고, 사용자가 보지 않을 수 있는 정보에 대해서도 작업을 진행할 수 있어서 비효율적
  2. 셀에서 처리할지 => 조금 더 적절해보인다.

마찬가지로 서버 통신을 셀에서 할 경우 셀이 꺼내질 때마다 요청이 들어가 call 수가 증가할 수 있다.

Alamofire의 데이터 받아오는 메서드

Serialization, Deserialization

Serialization

  • 직렬화
  • Encoding
  • 외부에서 알아들을 수 있는 형태로 변환

Deserialization

  • 역직렬화
  • Decoding
  • 시스템에서 사용할 수 있는 형태로 변환

Pagination

swift에서 구현하기

  1. will display cell 이용
  • 셀이 그려지기 전에 호출, 실제 셀을 그려주는 역할은 cell for row at이 함
  • 예상치 못한 방식으로 동작할 수 있음
  1. scrollView의 scroll 시점 이용
  • 많이 쓰이는 방식
  • contents의 끝에 도착했을 때 delegate method를 호출해서 적절한 처리를 해주면 됨
  • contentSize, contentOffset 개념을 이해해야 함
  1. DataSourcePrefetching 프로토콜 이용
  • 가장 적합한 방식에 가까움
  • 작업 취소 기능도 포함 (만약 사용자가 스크롤을 너무 빨리 한다면 중간 중간 취소를 하는 것이 효율적일 수 있기 때문에 적절한 상황에 이용하기)

클로저

  • 이름이 있는 함수 = 메서드 함수
  • 이름이 없는 함수 = 클로저 함수
@Taehyeon-Kim
Copy link
Owner Author

swift-10

@Taehyeon-Kim
Copy link
Owner Author

swift-11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant