μλ² ν΅μ μ μ μ 보μ¬μ€ UIImage λ³ν μμ
urlString βΆοΈ url βΆοΈ image
urlλ‘ λ°κΎΈκ³ λλ imageλ‘ λ°κΎΈλ κ³Όμ μ μ΄λμμ μ§ννλ κ²μ΄ μ’μκΉ?
- μλ² ν΅μ μμ μμ ν μ§ => μκ°μ΄ μ€λκ±Έλ¦¬κ³ , μ¬μ©μκ° λ³΄μ§ μμ μ μλ μ 보μ λν΄μλ μμ μ μ§νν μ μμ΄μ λΉν¨μ¨μ
- μ μμ μ²λ¦¬ν μ§ => μ‘°κΈ λ μ μ ν΄λ³΄μΈλ€.
λ§μ°¬κ°μ§λ‘ μλ² ν΅μ μ μ μμ ν κ²½μ° μ μ΄ κΊΌλ΄μ§ λλ§λ€ μμ²μ΄ λ€μ΄κ° call μκ° μ¦κ°ν μ μλ€.
Alamofireμ λ°μ΄ν° λ°μμ€λ λ©μλ(Response Handler)
// Response Handler - Unserialized Response
func response(queue: DispatchQueue = .main,
completionHandler: @escaping (AFDataResponse<Data?>) -> Void) -> Self
// Response Serializer Handler - Serialize using the passed Serializer
func response<Serializer: DataResponseSerializerProtocol>(queue: DispatchQueue = .main,
responseSerializer: Serializer,
completionHandler: @escaping (AFDataResponse<Serializer.SerializedObject>) -> Void) -> Self
// Response Data Handler - Serialized into Data
func responseData(queue: DispatchQueue = .main,
dataPreprocessor: DataPreprocessor = DataResponseSerializer.defaultDataPreprocessor,
emptyResponseCodes: Set<Int> = DataResponseSerializer.defaultEmptyResponseCodes,
emptyRequestMethods: Set<HTTPMethod> = DataResponseSerializer.defaultEmptyRequestMethods,
completionHandler: @escaping (AFDataResponse<Data>) -> Void) -> Self
// Response String Handler - Serialized into String
func responseString(queue: DispatchQueue = .main,
dataPreprocessor: DataPreprocessor = StringResponseSerializer.defaultDataPreprocessor,
encoding: String.Encoding? = nil,
emptyResponseCodes: Set<Int> = StringResponseSerializer.defaultEmptyResponseCodes,
emptyRequestMethods: Set<HTTPMethod> = StringResponseSerializer.defaultEmptyRequestMethods,
completionHandler: @escaping (AFDataResponse<String>) -> Void) -> Self
// Response Decodable Handler - Serialized into Decodable Type
func responseDecodable<T: Decodable>(of type: T.Type = T.self,
queue: DispatchQueue = .main,
dataPreprocessor: DataPreprocessor = DecodableResponseSerializer<T>.defaultDataPreprocessor,
decoder: DataDecoder = JSONDecoder(),
emptyResponseCodes: Set<Int> = DecodableResponseSerializer<T>.defaultEmptyResponseCodes,
emptyRequestMethods: Set<HTTPMethod> = DecodableResponseSerializer<T>.defaultEmptyRequestMethods,
completionHandler: @escaping (AFDataResponse<T>) -> Void) -> Self
1. response
2. response<Serializer: DataResponseSerializerProtocol>
3. responseData
4. responseString
5. responseDecodable
6. responseJSON : ν΄λΉ λ©μλλ Alamofire 6 λΆν° deprecated λΌμ 곡μ λ¬Έμμλ μ¬λΌμ‘λ보λ€.
Serialization, Deserialization
Serialization
- μ§λ ¬ν
- Encoding
- μΈλΆμμ μμλ€μ μ μλ ννλ‘ λ³ν
Deserialization
- μμ§λ ¬ν
- Decoding
- μμ€ν μμ μ¬μ©ν μ μλ ννλ‘ λ³ν
Pagination
swiftμμ ꡬννκΈ°
- will display cell μ΄μ©
- μ μ΄ κ·Έλ €μ§κΈ° μ μ νΈμΆ, μ€μ μ μ κ·Έλ €μ£Όλ μν μ cell for row atμ΄ ν¨
- μμμΉ λͺ»ν λ°©μμΌλ‘ λμν μ μμ
- scrollViewμ scroll μμ μ΄μ©
- λ§μ΄ μ°μ΄λ λ°©μ
- contentsμ λμ λμ°©νμ λ delegate methodλ₯Ό νΈμΆν΄μ μ μ ν μ²λ¦¬λ₯Ό ν΄μ£Όλ©΄ λ¨
- contentSize, contentOffset κ°λ μ μ΄ν΄ν΄μΌ ν¨
- DataSourcePrefetching νλ‘ν μ½ μ΄μ©
- κ°μ₯ μ ν©ν λ°©μμ κ°κΉμ
- μμ μ·¨μ κΈ°λ₯λ ν¬ν¨ (λ§μ½ μ¬μ©μκ° μ€ν¬λ‘€μ λ무 빨리 νλ€λ©΄ μ€κ° μ€κ° μ·¨μλ₯Ό νλ κ²μ΄ ν¨μ¨μ μΌ μ μκΈ° λλ¬Έμ μ μ ν μν©μ μ΄μ©νκΈ°)
ν΄λ‘μ
- μ΄λ¦μ΄ μλ ν¨μ = λ©μλ ν¨μ
- μ΄λ¦μ΄ μλ ν¨μ = ν΄λ‘μ ν¨μ
+ νκΈ°ν κ²
'π± SeSAC' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
[SeSAC] 220808 TIL (0) | 2022.08.12 |
---|---|
[SeSAC] 220805 TIL (2) | 2022.08.10 |
[SeSAC] 220803 TIL (0) | 2022.08.10 |
[SeSAC] 220802 TIL (0) | 2022.08.10 |
[SeSAC] 220801 TIL (0) | 2022.08.10 |