iOS
protokol SomeProtocol {} func test1_1(dəyər: SomeProtocol) {} func test1_2(dəyər: any SomeProtocol) {}
protokol SomeProtocol {} func test1_1(dəyər: SomeProtocol) {} func test2_1(dəyər: some SomeProtocol) {} func test1_2(dəyər: any SomeProtocol) {}
son sinf 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) } }
Şəbəkə qatından başqa layihədə başqa makroslar var mı?
İndiyə qədər GCD və ya Modern Concurrency (async/await) istifadə edirsinizmi yeni vəzifələr üçün, əlaqəli olanlar üçün?
Öz -> Tapşırıq -> (güclü) Öz .... Geri -> View desinit -> View model deinit?
UIKit-də View və ViewModel necə əlaqə qurur — bağlamalar üçün RxSwift/Combine kimi bir şey istifadə olunurmu?
@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("Şəkli yükləməkdə xəta: \(error)") } } } Button("Yüklə") { onDownloadPhoto(url) }
```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 Görünüşe göre amaç, SwiftUI'da bir düğme stilini özelleştirmek ve padding, ön plan rengi, çerçeve genişliği, arka plan rengi ve şekil gibi farklı modifikasyonlar denemektir. Muhtemelen soru, istenen görünüm veya davranışı elde etmek için düğme stilini düzeltmek veya geliştirmekle ilgilidir; örneğin, düğmenin kullanılabilir genişliği kadar geniş olmasını sağlamak veya görsel stilini ayarlamak gibi.
```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 } } } ```
Əgər SwiftUI-də dizayn sisteminə müxtəlif üslublar (əsas/ikincil) ilə təkrar istifadə oluna bilən düymə komponenti dizayn etsəniz, bunu necə həyata keçirərdiniz?
İA alətləri (Cursor, Proxyman və s.) işdə daha məhsuldar olmağa nə dərəcədə kömək edir?
Qısa təqdim edin və hazırkı işinizi təsvir edin.
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)) } }
Birbaşa işlədiyiniz modullarda rəqabət problemləri (Sendable, yoxlanmamış Sendable, aktyorlar arasında keçidlər) baş verdi?
Son layihəniz haqqında daha ətraflı danışın — Avito-da foto qalereya modulu, siz cavabdeh olduğunuz (qısa müddətli icarə, rezervasiya forması və s.)
protokol SomeProtocol { func test() } func test1_1(dəyər: SomeProtocol) {} func test1_2(dəyər: any SomeProtocol) {} func test2_1(dəyər: some SomeProtocol) {} func test2_2<Dəyər: SomeProtocol>(dəyər: Dəyər) {} class A { func test2_2<Dəyər: SomeProtocol>(dəyər: Dəyər) { } } class B: SomeProtocol { func test() {} } class C: B {} A().test2_2(dəyər: B())
DispatchQueue ilə WorkItem istifadə edərkən və cancel() çağırıldıqda ləğv etmə nə zaman və necə baş verir?
Niyə önbellek yaddaşı kimi lüğət seçdiniz?
UIKit və SwiftUI-də təqdimat modulları üçün nə istifadə olunur — hansı memarlıq?