iOS
Ποιο είναι το ελάχιστο στόχο iOS στο έργο τώρα;
Ποια έκδοση της γλώσσας Swift χρησιμοποιείται στο έργο — πάνω από 6 ή κάτω;
πρωτόκολλο SomeProtocol {} func test1_1(τιμή: SomeProtocol) {} func test1_2(τιμή: any SomeProtocol) {}
Χρησιμοποιείτε την αρχιτεκτονική Viper για το UIKit; Ισχύει για όλες τις εφαρμογές;
πρωτόκολλο SomeProtocol {} func test1_1(τιμή: SomeProtocol) {} func test2_1(τιμή: some SomeProtocol) {} func test1_2(τιμή: any SomeProtocol) {}
struct ExampleView: View { @State var isVariant1 = true var body: some View { VStack { Toggle("Χρησιμοποιήστε την Παραλλαγή 1", isOn: $isVariant1.animation(.linear)) Text(isVariant1 ? "Παραλλαγή 1" : "Παραλλαγή 2") } .padding() } } Παραλλαγή1 -> κλίμακα -> 1 -> 0 Παραλλαγή2 -> κλίμακα -> 0
τελική κλάση NetworkService { func request<Response: Decodable, Body: Encodable>(urlString: String, method: HTTPMethod, body: Body? = nil, headers: [String: String] = [:], query: [String: String] = [:]) async throws -> Response { guard var components = URLComponents(string: urlString) else { throw Errors.invalidUrl } if !query.isEmpty { components.queryItems = query.map { URLQueryItem(name: $0.key, value: $0.value) } } guard let url = components.url else { throw Errors.invalidQuery } var request = URLRequest(url: url) request.httpMethod = method.rawValue headers.forEach { request.setValue($0.value, forHTTPHeaderField: $0.key) } if let body, method == .post { request.httpBody = try encoder.encode(body) // ? } let (data, response) = try await session.data(for: request) guard let httpResponse = response as? HTTPURLResponse else { throw Errors.invalidResponse } guard (200...299).contains(httpResponse.statusCode) else { throw Errors.httpStatus(httpResponse.statusCode) } return try decoder.decode(Response.self, from: data) } }
Χρησιμοποιείτε αυτήν τη στιγμή GCD ή Modern Concurrency (async/await) για νέες εργασίες που σχετίζονται με νήματα;
Self -> Task -> (strong) Self .... Πίσω -> View desinit -> View model deinit?
@MainActor final class ViewModel: ObservableObject { @Published var image: UIImage? func onDownloadPhoto(url: URL) { do { let data = try Data(contentsOf: url) image = UIImage.init(data: data) } catch { log.error("Αποτυχία λήψης εικόνας: \(error)") } } } Button("Λήψη") { onDownloadPhoto(url) }
Σε ποιο βαθμό σε βοηθούν τα εργαλεία ΤΝ (Cursor, Proxyman κ.ά.) να είσαι πιο παραγωγικός στη δουλειά;
```swift struct ContentView: View { var body: some View { ScrollView { content .padding(20) } .background(Color(.systemGroupedBackground)) .overlay(alignment: .bottom) { continueButton } } } ``` ```swift struct ContentView: View { var body: some View { ScrollView { content .padding(20) } .background(Color(.systemGroupedBackground)) .safeAreaInset(edge: .bottom) { continueButton } } } ```
```swift struct CustomButtonStyleView: View { var body: some View { VStack { Button("Button") { print("Tapped") } .buttonStyle(CustomButtonStyle()) } } } private struct CustomButtonStyle: ButtonStyle { func makeBody(configuration: Configuration) -> some View { configuration.label .padding() .foregroundColor(.white) .background(Color.red) .clipShape(RoundedRectangle(cornerRadius: 8)) } } ``` ```swift struct CustomButtonStyleView: View { var body: some View { VStack { Button("Button") { print("Tapped") } .buttonStyle(CustomButtonStyle()) } } } private struct CustomButtonStyle: ButtonStyle { func makeBody(configuration: Configuration) -> some View { configuration.label .padding() .foregroundColor(.white) .frame(maxWidth?) .background(Color.red) .clipShape(RoundedRectangle(cornerRadius: 8)) } } ``` ```swift struct CustomButtonStyleView: View { var body: some View { VStack { Button("Button") { print("Tapped") } .buttonStyle(CustomButtonStyle()) } } } private struct CustomButtonStyle: ButtonStyle { func makeBody(configuration: Configuration) -> some View { configuration.label .padding() .foregroundColor(.white) .frame(maxWidth?) .background(Color.red) .clipShape(RoundedRectangle(cornerRadius: 8)) } } ``` ```swift struct CustomButtonStyleView: View { var body: some View { VStack { Button("Button") { print("Tapped") } .buttonStyle(CustomButtonStyle()) } } } private struct CustomButtonStyle: ButtonStyle { func makeBody(configuration: Configuration) -> some View { configuration.label //.padding() //.foregroundColor(.white) .frame(maxWidth: .infinity) .background(Color.red) //.clipShape(RoundedRectangle(cornerRadius: 8)) } } ``` ```swift struct CustomButtonStyleView: View { var body: some View { VStack { Button("Button") { print("Tapped") } .buttonStyle(CustomButtonStyle()) .frame(width: 200) } } } private struct CustomButtonStyle: ButtonStyle { func makeBody(configuration: Configuration) -> some View { configuration.label //.padding() //.foregroundColor(.white) .frame(maxWidth: .infinity) .background(Color.red) //.clipShape(RoundedRectangle(cornerRadius: 8)) } } ```\n Φαίνεται ότι ο στόχος είναι να προσαρμόσετε ένα στυλ κουμπιού SwiftUI, πειραματιζόμενοι με διαφορετικούς τροποποιητές όπως padding, χρώμα μπροστινού, πλάτος πλαισίου, χρώμα φόντου και σχήμα περικοπής. Η ερώτηση πιθανώς αφορά τη διόρθωση ή βελτίωση του στυλ του κουμπιού για να επιτευχθεί μια επιθυμητή εμφάνιση ή συμπεριφορά, όπως το να γεμίζει το διαθέσιμο πλάτος ή η ρύθμιση του οπτικού στυλ του.
Υπήρχαν προβλήματα με τον ανταγωνισμό (Sendable, unchecked Sendable, μετάβαση μεταξύ ηθοποιών) στα modules που εργάστηκες άμεσα;
Γιατί επιλέξατε ένα λεξικό ως αποθήκευση cache;
struct CustomButtonStyleView: View { var body: some View { VStack { Button("Button") { print("Tapped") } } .buttonStyle(CustomButtonStyle()) } } private struct CustomButtonStyle: ButtonStyle { func makeBody(configuration: Configuration) -> some View { configuration.label .padding() .foregroundColor(.white) .frame(maxWidth: .infinity) .background(Color.red) .clipShape(RoundedRectangle(cornerRadius: 8)) } }
Τι χρησιμοποιείται για τα παρουσιάσιμα modules στο UIKit και SwiftUI — ποια αρχιτεκτονική;
Πες μου περισσότερα για το τελευταίο σου έργο — το module της φωτογραφικής γκαλερί στο Avito, για το οποίο ήσουν υπεύθυνος (βραχυπρόθεσμη ενοικίαση, φόρμα κράτησης κ.λπ.)
πρωτόκολλο SomeProtocol { func test() } func test1_1(τιμή: SomeProtocol) {} func test1_2(τιμή: any SomeProtocol) {} func test2_1(τιμή: some SomeProtocol) {} func test2_2<Τιμή: SomeProtocol>(τιμή: Τιμή) {} class A { func test2_2<Τιμή: SomeProtocol>(τιμή: Τιμή) { } } class B: SomeProtocol { func test() {} } class C: B {} A().test2_2(τιμή: B())
Πότε και πώς πραγματοποιείται η ακύρωση όταν χρησιμοποιείται το DispatchQueue με WorkItem και καλείται η cancel();