Sobes.tech

SomeProtocol პროტოკოლი {} ფუნქცია test1_1 მნიშვნელობა: SomeProtocol {} ფუნქცია test2_1 მნიშვნელობა: some SomeProtocol {} ფუნქცია test1_2 მნიშვნელობა: any SomeProtocol {}

Senior
Salmon
40

როდესაც პროექტზე მოხვდი, უკვე იყო Swift 6, თუ ტრანსიცია შენთან მოხდა?

Senior
Salmon
40

პროტოკოლი SomeProtocol {} func test1_1(ღირებულება: SomeProtocol) {} func test1_2(ღირებულება: any SomeProtocol) {}

Senior
Salmon
40

ამჟამად იყენებთ GCD ან Modern Concurrency (async/await) ახალი დავალებებისთვის, რომლებიც დაკავშირებულია ძაფებთან?

Senior
Salmon
39

როგორ מתקשרות View და ViewModel UIKit-ში — გამოიყენება რამე მსგავსი RxSwift/Combine ბინდინგებისთვის?

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?) .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)) } } ``` Вызывается задача о настройке стиля кнопки SwiftUI, экспериментировании с различными модификаторами, такими как отступы, цвет переднего плана, ширина рамки, цвет фона и форма обрезки. Вероятно, вопрос включает исправление или улучшение стиля кнопки для достижения желаемого внешнего вида или поведения, например, чтобы кнопка заполняла доступную ширину или настраивала ее визуальный стиль.

Senior
Salmon
38

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

ბოლოსადი კლასი 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+
СБЕРСБЕР
36

როდის და როგორ ხდება გაუქმება, როდესაც იყენებთ DispatchQueue-სთან ერთად WorkItem-ს და გამოიძახებთ cancel()-ს?

Senior
Salmon
35

Self -> დავალება -> (ძლიერი) Self .... უკან -> View desinit -> View model deinit?

Senior
Salmon
34

პროტოკოლი SomeProtocol { func test() } func test1_1(მნიშვნელობა: SomeProtocol) {} func test1_2(მნიშვნელობა: any SomeProtocol) {} func test2_1(მნიშვნელობა: some SomeProtocol) {} func test2_2<მნიშვნელობა: SomeProtocol>(მნიშვნელობა: მნიშვნელობა) {} class A { func test2_2<მნიშვნელობა: SomeProtocol>(მნიშვნელობა: მნიშვნელობა) { } } class B: SomeProtocol { func test() {} } class C: B {} A().test2_2(მნიშვნელობა: B())

Senior
Salmon
34

თუ თქვენ პროექტირებთ მრავალჯერადი ღილაკის კომპონენტს SwiftUI-ის დიზაინის სისტემისთვის სხვადასხვა სტილებით (პირველადი/მეორეული), როგორ განახორციელებდით ამას?

Senior
Salmon
34

შეიძლება პირდაპირ მუშაობდით მოდულებში კონკურენციის პრობლემები (Sendable, unchecked Sendable, მსახიობებს შორის გადასვლები)?

Senior
Salmon
34

რა გამოიყენება UIKit და SwiftUI-ის პრეზენტაციული მოდულებისთვის — რა არქიტექტურა?

Senior
Salmon
33

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

Senior
Salmon
32

მოკლედ წარუდგით თავი და აღწერეთ თქვენი მიმდინარე სამუშაო.

Middle+
RevolutRevolut
31

გთხოვთ, უფრო დეტალურად ისაუბროთ თქვენს ბოლო პროექტზე — ფოტოგალერეის მოდული ავიტოში, რომლის პასუხისმგებელიც იყავით (მოკლე ვადიანი გაქირავება, ბილეთის ფორმა და ა.შ.)

Senior
Salmon
31

ბოლო WWDC-ზე საინტერესო სესია/ჩარჩოები იყო, რომლებსაც გსურთ თქვენი მუშაობაში სცადოთ?

Senior
Salmon
30

პროექტში სხვა მაკროები არსებობს თუ არა ქსელის ფენას გარდა?

Senior
Salmon
30
/206