Sobes.tech

iOS

protokol SomeProtocol {} func test1_1(dəyər: SomeProtocol) {} func test1_2(dəyər: any SomeProtocol) {}

Senior
Salmon
42

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) {}

Senior
Salmon
41

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) } }

Middle+
СБЕРСБЕР
41

Şəbəkə qatından başqa layihədə başqa makroslar var mı?

Senior
Salmon
41

İndiyə qədər GCD və ya Modern Concurrency (async/await) istifadə edirsinizmi yeni vəzifələr üçün, əlaqəli olanlar üçün?

Senior
Salmon
40

Öz -> Tapşırıq -> (güclü) Öz .... Geri -> View desinit -> View model deinit?

Senior
Salmon
39

UIKit-də View və ViewModel necə əlaqə qurur — bağlamalar üçün RxSwift/Combine kimi bir şey istifadə olunurmu?

Senior
Salmon
39

@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) }

Senior
Salmon
39

```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.

Senior
Salmon
39

```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 } } } ```

Senior
Salmon
38

Ə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?

Senior
Salmon
38

İA alətləri (Cursor, Proxyman və s.) işdə daha məhsuldar olmağa nə dərəcədə kömək edir?

Senior
Salmon
38

Qısa təqdim edin və hazırkı işinizi təsvir edin.

Middle+
RevolutRevolut
37

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)) } }

Senior
Salmon
37

Birbaşa işlədiyiniz modullarda rəqabət problemləri (Sendable, yoxlanmamış Sendable, aktyorlar arasında keçidlər) baş verdi?

Senior
Salmon
37

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.)

Senior
Salmon
36

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())

Senior
Salmon
35

DispatchQueue ilə WorkItem istifadə edərkən və cancel() çağırıldıqda ləğv etmə nə zaman və necə baş verir?

Senior
Salmon
35

Niyə önbellek yaddaşı kimi lüğət seçdiniz?

Middle+
RevolutRevolut
35

UIKit və SwiftUI-də təqdimat modulları üçün nə istifadə olunur — hansı memarlıq?

Senior
Salmon
34
/206