Sobes.tech

iOS

protokol SomeProtocol {} func test1_1(hodnota: SomeProtocol) {} func test2_1(hodnota: some SomeProtocol) {} func test1_2(hodnota: any SomeProtocol) {}

Senior
Salmon
48

Existujú v projekte ďalšie makrá okrem sieťovej vrstvy?

Senior
Salmon
48

Prečo aktuálny kód s nekonečnou slučkou for v main ne funguje? Ako to opraviť?

Principal
Позитив Технолоджис
48

Aký je aktuálny minimálny cieľ iOS v projekte?

Senior
Salmon
45

@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("Nepodarilo sať stiahnuť obrázok: \(error)") } } } Button("Stiahnuť") { onDownloadPhoto(url) }

Senior
Salmon
44

Používate architektúru Viper pre UIKit? Platí to pre všetky aplikácie?

Senior
Salmon
44

struct ExampleView: View { @State var isVariant1 = true var body: some View { VStack { Toggle("Použiť Variantu 1", isOn: $isVariant1.animation(.linear)) Text(isVariant1 ? "Varianta 1" : "Varianta 2") } .padding() } } Varianta1 -> mierka -> 1 -> 0 Varianta2 -> mierka -> 0

Senior
Salmon
43

záverečná trieda 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+
СБЕРСБЕР
42

Self -> Úloha -> (silný) Self .... Späť -> View desinit -> View model deinit?

Senior
Salmon
42

Čo sa používa pre prezentačné moduly v UIKit a SwiftUI — aká architektúra?

Senior
Salmon
42

Boli problémy s konkurentnosťou (Sendable, unchecked Sendable, prehody medzi aktérmi) v moduloch, s ktorými ste priamo pracovali?

Senior
Salmon
42

Prečo ste si vybrali slovník ako úložisko cache?

Middle+
RevolutRevolut
42

Ako veľmi ti pomáhajú nástroje AI (Cursor, Proxyman atď.) byť produktívnejší v práci?

Senior
Salmon
42

Používate momentálne GCD alebo Modern Concurrency (async/await) pre nové úlohy súvisiace s vláknami?

Senior
Salmon
40

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

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

Senior
Salmon
39

Kedy a ako dochádza k zrušeniu pri použití DispatchQueue s WorkItem a volaní cancel()?

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

Povedaj mi več o svojem zadnjem projektu — modulu fotogalerije na Avito, za katerega si bio odgovoran (kratkoročni najem, obrazec za rezervacijo itd.)

Senior
Salmon
37

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

Senior
Salmon
36
/206