iOS
protokol SomeProtocol {} func test1_1(hodnota: SomeProtocol) {} func test2_1(hodnota: some SomeProtocol) {} func test1_2(hodnota: any SomeProtocol) {}
Existujú v projekte ďalšie makrá okrem sieťovej vrstvy?
Prečo aktuálny kód s nekonečnou slučkou for v main ne funguje? Ako to opraviť?
Aký je aktuálny minimálny cieľ iOS v projekte?
@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("Nepodarilo sať stiahnuť obrázok: \(error)") } } } Button("Stiahnuť") { onDownloadPhoto(url) }
Používate architektúru Viper pre UIKit? Platí to pre všetky aplikácie?
struct ExampleView: View { @State var isVariant1 = true var body: some View { VStack { Toggle("Použiť Variantu 1", isOn: $isVariant1.animation(.linear)) Text(isVariant1 ? "Varianta 1" : "Varianta 2") } .padding() } } Varianta1 -> mierka -> 1 -> 0 Varianta2 -> mierka -> 0
záverečná trieda 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) } }
Self -> Úloha -> (silný) Self .... Späť -> View desinit -> View model deinit?
Čo sa používa pre prezentačné moduly v UIKit a SwiftUI — aká architektúra?
Boli problémy s konkurentnosťou (Sendable, unchecked Sendable, prehody medzi aktérmi) v moduloch, s ktorými ste priamo pracovali?
Prečo ste si vybrali slovník ako úložisko cache?
Ako veľmi ti pomáhajú nástroje AI (Cursor, Proxyman atď.) byť produktívnejší v práci?
Používate momentálne GCD alebo Modern Concurrency (async/await) pre nové úlohy súvisiace s vláknami?
```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: .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)) } } ``` Výzva se zdá být o přizpůsobení stylu tlačítka SwiftUI, experimentování s různými modifikátory, jako je odsazení, barva popředí, šířka rámečku, barva pozadí a tvar oříznutí. Otázka pravděpodobně zahrnuje opravu nebo vylepšení stylu tlačítka tak, aby dosáhla požadovaného vzhledu nebo chování, například aby tlačítko vyplnilo dostupnou šířku nebo upravit jeho vizuální styl.
Kedy a ako dochádza k zrušeniu pri použití DispatchQueue s WorkItem a volaní cancel()?
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)) } }
Povedaj mi več o svojem zadnjem projektu — modulu fotogalerije na Avito, za katerega si bio odgovoran (kratkoročni najem, obrazec za rezervacijo itd.)
protokol SomeProtocol { func test() } func test1_1(hodnota: SomeProtocol) {} func test1_2(hodnota: any SomeProtocol) {} func test2_1(hodnota: some SomeProtocol) {} func test2_2<Hodnota: SomeProtocol>(hodnota: Hodnota) {} class A { func test2_2<Hodnota: SomeProtocol>(hodnota: Hodnota) { } } class B: SomeProtocol { func test() {} } class C: B {} A().test2_2(hodnota: B())