iOS
Ինչպես են հաղորդակցվում View և ViewModel-ը UIKit-ում — օգտագործվում է ինչ-որ բան, ինչպես RxSwift/Combine բինդինգների համար?
Կա՞ն այլ մակրոներ նախագծում բացի ցանցային շերտից։
Ինչու է ներկայիս կոդը, որը պարունակում է անսահման for ցիկլ main-ում, չի աշխատում: Ինչպես դա ուղղել?
Ի՞նչ տարբերակ է օգտագործվում Swift լեզվում՝ ավելի բարձր 6-ից կամ ցածր?
Ի՞նչ է ներկայումս նվազագույն iOS նպատակն նախագծում։
Օգտագործում եք Viper ճարտարապետությունը UIKit-ի համար: Դա վերաբերում է բոլոր հավելվածներին:
@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) }
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) } }
Ինչու եք ընտրել բառարան որպես կեշ պահեստավորում?
Ի՞նչ չափով են Ձեզ օգնում արհեստական բանականության գործիքները (Cursor, Proxyman և այլն) աշխատունակությունը բարձրացնելուն:
Self -> Տվյալ -> (ուժեղ) Self .... Հետ -> View desinit -> View model deinit?
Դուք արդյոք ներկայում օգտագործում եք GCD կամ Modern Concurrency (async/await) նոր առաջադրանքների համար, որոնք կապված են թելերով?
Ի՞նչ է օգտագործվում UIKit և SwiftUI-ում ներկայացման մոդուլների համար — ո՞ր ճարտարապետությունն է:
```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 } } } ```
Կա՞ն խնդիրներ մրցակցայինության հետ (Sendable, unchecked Sendable, անցումներ դերակատարների միջև) այն մոդուլներում, որոնց հետ դուք ուղղակի աշխատել եք։
```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.
Երբ և ինչպես է տեղի ունենում չեղարկումը, երբ օգտագործվում է DispatchQueue-ով WorkItem և կանչվում է 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)) } }
Ավելացրեք ավելի մանրամասն ձեր վերջին նախագծի մասին — լուսանկարների գալերեայի մոդուլը Ավիտոյում, որի պատասխանատուն եք (կարճաժամկետ վարձակալություն, ամրագրման ձևանմուշ և այլն)