Sobes.tech

iOS

SomeProtocol protokoli {} func test1_1(qiymat: SomeProtocol) {} func test2_1(qiymat: some SomeProtocol) {} func test1_2(qiymat: any SomeProtocol) {}

Senior
Salmon
40

Loyihaga kelganingizda, Swift 6 allaqachon mavjud edimi yoki o'tish sizning ishtirokingizda bo'ldimi?

Senior
Salmon
40

Hozirda iplar bilan bog'liq yangi vazifalar uchun GCD yoki Modern Concurrency (async/await) dan foydalanayapsizmi?

Senior
Salmon
40

protokol SomeProtocol {} func test1_1(qiymat: SomeProtocol) {} func test1_2(qiymat: any SomeProtocol) {}

Senior
Salmon
40

UIKitda View va ViewModel qanday muloqot qiladi — bindinglar uchun RxSwift/Combine kabi narsalar ishlatiladimi?

Senior
Salmon
38

```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)) } } ``` Obywa się wydaje, że celem jest dostosowanie stylu przycisku SwiftUI, eksperymentując z różnymi modyfikatorami takimi jak padding, kolor pierwszego planu, szerokość ramki, kolor tła i kształt przycinania. Prawdopodobnie pytanie dotyczy naprawy lub ulepszenia stylu przycisku, aby osiągnąć pożądany wygląd lub zachowanie, na przykład sprawić, by przycisk wypełnił całą dostępną szerokość lub dostosować jego styl wizualny.

Senior
Salmon
38

oxirgi 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+
СБЕРСБЕР
37

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

DispatchQueue bilan WorkItem dan foydalanib va cancel() chaqirilganda bekor qilish qachon va qanday amalga oshadi?

Senior
Salmon
35

O'zini -> Vazifa -> (kuchli) O'zini .... Orqaga -> View desinit -> View model deinit?

Senior
Salmon
34

protokol SomeProtocol { func test() } func test1_1(qiymat: SomeProtocol) {} func test1_2(qiymat: any SomeProtocol) {} func test2_1(qiymat: some SomeProtocol) {} func test2_2<Qiymat: SomeProtocol>(qiymat: Qiymat) {} class A { func test2_2<Qiymat: SomeProtocol>(qiymat: Qiymat) { } } class B: SomeProtocol { func test() {} } class C: B {} A().test2_2(qiymat: B())

Senior
Salmon
34

Agar siz SwiftUI'da dizayn tizim uchun turli uslublar (asosiy/ikkinchi) bilan qayta ishlatiladigan tugma komponentini loyihalasangiz, uni qanday amalga oshirasiz?

Senior
Salmon
34

To'g'ridan-to'g'ri ishlagan modullarda raqobat muammolari (Sendable, unchecked Sendable, aktyorlar o'rtasidagi o'tishlar) bo'ldimi?

Senior
Salmon
34

UIKit va SwiftUI'da taqdimot modullari uchun nima ishlatiladi — qaysi arxitektura?

Senior
Salmon
33

O'zingizni qisqacha tanishtiring va hozirgi ishingiz haqida tavsif bering.

Middle+
RevolutRevolut
32

@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("Rasmni yuklab olishda xato: \(error)") } } } Button("Yuklab olish") { onDownloadPhoto(url) }

Senior
Salmon
32

O'z oxirgi loyihangiz haqida batafsilroq gapiring — Avito'dagi foto galereya moduli, siz javobgar bo'lgan (qisqa muddatli ijaraga olish, bron qilish shakli va boshqalar)

Senior
Salmon
32

So'nggi WWDCda qiziqarli sessiyalar yoki freymvorklar bo'ldimi va ularni ishda sinab ko'rishni xohlaysizmi?

Senior
Salmon
30

Tarmoq qatlamidan tashqari loyiha ichida boshqa makroslar bormi?

Senior
Salmon
30
/206