iOS
protocol SomeProtocol {} func test1_1(waarde: SomeProtocol) {} func test1_2(waarde: any SomeProtocol) {}
Toen je bij het project kwam, was Swift 6 er al, of vond de overgang plaats tijdens jouw aanwezigheid?
Gebruikt u momenteel GCD of Modern Concurrency (async/await) voor nieuwe taken gerelateerd aan threads?
Hoe communiceren View en ViewModel in UIKit — wordt er iets zoals RxSwift/Combine gebruikt voor bindingen?
```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: .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)) } } ``` Het lijkt erop dat het doel is om een SwiftUI-knopstijl aan te passen, door te experimenteren met verschillende modifiers zoals padding, voorgrondkleur, framebreedte, achtergrondkleur en knipvorm. De vraag gaat waarschijnlijk over het corrigeren of verbeteren van de knopstijl om een gewenst uiterlijk of gedrag te bereiken, zoals het laten vullen van de beschikbare breedte of het aanpassen van de visuele stijl.
```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 } } } ```
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)) } }
laatste klasse 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) } }
Wanneer en hoe vindt de annulering plaats bij het gebruik van DispatchQueue met WorkItem en het aanroepen van cancel()?
Zelf -> Taak -> (sterk) Zelf .... Terug -> View desinit -> View model deinit?
protocol SomeProtocol { func test() } func test1_1(waarde: SomeProtocol) {} func test1_2(waarde: any SomeProtocol) {} func test2_1(waarde: some SomeProtocol) {} func test2_2<Waarde: SomeProtocol>(waarde: Waarde) {} class A { func test2_2<Waarde: SomeProtocol>(waarde: Waarde) { } } class B: SomeProtocol { func test() {} } class C: B {} A().test2_2(waarde: B())
Als je een herbruikbaar knopcomponent zou ontwerpen voor een design-systeem in SwiftUI met verschillende stijlen (primair/secundair), hoe zou je dat implementeren?
Hadden zich problemen met gelijktijdigheid (Sendable, unchecked Sendable, overgang tussen actoren) in de modules waarmee je direct werkte?
Wat wordt gebruikt voor presentatiemodules in UIKit en SwiftUI — welke architectuur?
@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("Fout bij het downloaden van afbeelding: \(error)") } } } Button("Download") { onDownloadPhoto(url) }
Stel jezelf kort voor en beschrijf je huidige werk.
Vertel me meer over je laatste project — de fotogalerijmodule op Avito, waarvoor je verantwoordelijk was (korte termijn verhuur, reserveringsformulier, etc.)
Zijn er interessante sessies/frameworks geweest op de laatste WWDC die je in je werk zou willen proberen?
Zijn er nog meer macro's in het project naast de netwerklaag?
protocol CacheProtocol { associatedtype Value func setValue(_ value: Value?, forKey key: String) func getValue(forKey key: String) -> Value? func fetchValue(forKey key: String, completion: @escaping (Value?) -> Void) } final class Cache<T>: CacheProtocol { private var storage: [String: T] = [:] func setValue(_ value: T?, forKey key: String) { storage[key] = value } func getValue(forKey key: String) -> T? { return storage[key] } func fetchValue(forKey key: String, completion: @escaping (T?) -> Void) { let value = storage[key] completion(value) } } import XCTest final class CacheTests: XCTestCase { override func setUp() { super.setUp() } func testSetAndGetValue() { let cache = Cache<String>() let key: String = "key" let value: String = "value" cache.setValue(value, forKey: key) XCTAssertEqual(cache.getValue(forKey: key), value) cache.setValue(nil, forKey: key) XCTAssertTrue(cache.getValue(forKey: key) == nil) } } CacheTests.defaultTestSuite.run()