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
// CODE 1 | |
class HTTPClient { | |
func load(url: URL, completion: @escaping (Response) -> Void) { | |
// call server | |
// complete with result | |
} | |
} | |
// Responsibilities: | |
/// - Send request and return response |
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
# Name which will be visible in Github Actions tab in repository | |
name: CI iOS | |
# Trigger which will run this workflow. (any pull request in main page) | |
on: | |
pull_request: | |
branches: [ main ] | |
jobs: | |
build-and-test: |
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 Foundation | |
let JSON = """ | |
[{ | |
"sub_elements": [{ | |
"sub_elements": [{ | |
"id": "4315FAC2-0809-478C-BED8-54F28B0A9A57", | |
"name": "Shape 1" | |
}, { | |
"id": "D2985D5B-B98A-4549-A4ED-3742583A2532", |
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
class Pagination<Element: Decodable>: Decodable { | |
var list: [Element] | |
var currentPage: Int | |
var totalPages: Int | |
enum ResultCodingKeys: String, CodingKey { | |
case list, currentPage, totalPages | |
} | |
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
class Pagination: Decodable { | |
var pets: [Pet] | |
var currentPage: Int | |
var totalPages: Int | |
enum ResultCodingKeys: String, CodingKey { | |
case pets, currentPage, totalPages | |
} | |
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
class Pagination: Decodable { | |
var cars: [Car] | |
var currentPage: Int | |
var totalPages: Int | |
enum ResultCodingKeys: String, CodingKey { | |
case cars, currentPage, totalPages | |
} | |
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
func handleDecoding<Element: Decodable>(responseData: Data, | |
responseType: Element.Type, | |
completion: @escaping (_ apiResponse: Element?, _ error: String?) -> Void) { | |
do { | |
let apiResponse = try JSONDecoder().decode(responseType, from: responseData) | |
completion(apiResponse, nil) | |
} catch { | |
completion(nil, "Network Error") | |
} | |
} |
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
// PetNetworkManager | |
func handleDecoding(responseData: Data, | |
completion: @escaping (_ apiResponse: Pet?, _ error: String?) -> Void) { | |
do { | |
let apiResponse = try JSONDecoder().decode(Pet.self, from: responseData) | |
completion(apiResponse, nil) | |
} catch { | |
completion(nil, "Network Error") | |
} | |
} |
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
# RESULT | |
node1 = SinglyLinkedListNode(1) | |
node2 = SinglyLinkedListNode(2) | |
node3 = SinglyLinkedListNode(3) | |
node1.next = node2 | |
node2.next = node3 | |
result = insertNodeAtHead(node1, 33) | |
current_node = result |
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
from linked_list import SinglyLinkedListNode | |
def insertNodeAtHead(llist, data): | |
node = SinglyLinkedListNode(data) | |
node.next = llist | |
return node |
NewerOlder