- 테스트앱
- 낮은 해상도 = 사진 크기: 10 ~ 50KB
- 중간 해상도 = 사진 크기: 100 ~ 500KB + 5MB
- 높은 해상도 = 사진 크기: 10 ~ 50MB
- 기본 설정 = 설정: 메모리 100MB 디스크 150MB
- 리사이즈 = (화면 너비 / 3)^2. iPhone 8+ 기준으로 414 pixel.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Promises | |
/// Check whether the values fulfill condition, and group the results. | |
/// - parameters: | |
/// - values: Values to check | |
/// - condition: Promise which states the condition | |
/// - returns: Promise which has grouped result of condition-passed values | |
public func filter<T>(values: [T], condition: ((T) -> Promise<Bool>)) -> Promise<[T]> { | |
let promises = values.map { value in condition(value).validate { $0 }.then { _ in value } } | |
return any(promises).then { $0.compactMap({ $0.value }) } |
- af_setImage method 를 사용하면, URLCache (애플 기본 클래스) 와 AutoPurgingImageCache (Dictionary) 를 사용한다.
- URLCache 는 원본을 갖고 있고, AutoPurgingImageCache 는 filter 를 씌운 결과를 가지고 있다.
- AutoPurgingImageCache 는 cachedImages 라는 array 를 들고 있다. disk 는 사용하지 않는다.
- 필터 기능을 사용하지 않는다면 URLSessionConfiguration 에서 URLCache 를 nil로 설정해야 불필요한 두 번 저장을 피할 수 있다.
NewerOlder