Sobes.tech

Vai izmantojat Viper arhitektūru UIKit? Vai tas attiecas uz visas lietojumprogrammas?

Senior
Salmon
42

protokols SomeProtocol {} funkcija test1_1 vērtība: SomeProtocol {} funkcija test2_1 vērtība: some SomeProtocol {} funkcija test1_2 vērtība: any SomeProtocol {}

Senior
Salmon
40

Vai šobrīd izmantojat GCD vai Modern Concurrency (async/await) jauniem uzdevumiem, kas saistīti ar pavedieniem?

Senior
Salmon
40

protokols SomeProtocol {} func test1_1(vērtība: SomeProtocol) {} func test1_2(vērtība: any SomeProtocol) {}

Senior
Salmon
40

Kā View un ViewModel sazinās UIKit — vai tiek izmantots kaut kas līdzīgs RxSwift/Combine saistībām?

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()) .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)) } } ```

Senior
Salmon
38

beidzamais klases NetworkService funkcija, kas veic tīkla pieprasījumus, ir rakstīta Swift valodā un izmanto asinhronas funkcijas ar ģeneriskajiem parametriem Response un Body, lai saskaņotu ar atbilstošajiem Decodable un Encodable protokoliem. Kods pārbauda URL, iestata galvenes, sūta pieprasījumu un apstrādā atbildi, pārbaudot statusa kodu un dekodējot datus atbilstoši Response tipam.

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

Kad un kā notiek atcelšana, izmantojot DispatchQueue ar WorkItem un izsaucot cancel()?

Senior
Salmon
35

Self -> Uzdevums -> (spēcīgs) Self .... Atpakaļ -> View desinit -> View model deinit?

Senior
Salmon
34

protokols SomeProtocol { func test() } func test1_1(uzdevums: SomeProtocol) {} func test1_2(uzdevums: any SomeProtocol) {} func test2_1(uzdevums: some SomeProtocol) {} func test2_2<Uzdevums: SomeProtocol>(uzdevums: Uzdevums) {} class A { func test2_2<Uzdevums: SomeProtocol>(uzdevums: Uzdevums) { } } class B: SomeProtocol { func test() {} } class C: B {} A().test2_2(uzdevums: B())

Senior
Salmon
34

Ja jūs projektētu atkārtoti lietojamu pogas komponentu SwiftUI dizaina sistēmai ar dažādiem stiliem (primārais/sekundārais), kā jūs to īstenotu?

Senior
Salmon
34

Vai bija problēmas ar konkurētspēju (Sendable, unchecked Sendable, pārejas starp aktieriem) moduļos, ar kuriem tieši strādājāt?

Senior
Salmon
34

Kas tiek izmantojams prezentācijas moduļiem UIKit un SwiftUI — kāda arhitektūra?

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("Neizdevās lejupielādēt attēlu: \(error)") } } } Button("Lejupielādēt") { onDownloadPhoto(url) }

Senior
Salmon
33

Īsi iepazīstiniet sevi un aprakstiet savu pašreizējo darbu.

Middle+
RevolutRevolut
32

Pastāsti vairāk par savu pēdējo projektu — foto galerijas moduli Avito, par kuru tu atbildēji (īslaicīga īre, rezervācijas veidlapa utt.)

Senior
Salmon
32

protokols CacheProtocol { associatedtype Value func setValue(_ value: Value?, forKey key: String) func getValue(forKey key: String) -> Value? func fetchValue(forKey key: String, completion: @escaping (Value?) -> Void) } final class Cache<T>: CacheProtocol { private var storage: [String: T] = [:] func setValue(_ value: T?, forKey key: String) { storage[key] = value } func getValue(forKey key: String) -> T? { return storage[key] } func fetchValue(forKey key: String, completion: @escaping (T?) -> Void) { let value = storage[key] completion(value) } } import XCTest final class CacheTests: XCTestCase { override func setUp() { super.setUp() } func testSetAndGetValue() { let cache = Cache<String>() let key: String = "key" let value: String = "value" cache.setValue(value, forKey: key) XCTAssertEqual(cache.getValue(forKey: key), value) cache.setValue(nil, forKey: key) XCTAssertTrue(cache.getValue(forKey: key) == nil) } } CacheTests.defaultTestSuite.run()

Middle+
RevolutRevolut
30

Vai pēdējā WWDC bija interesantas sesijas/rāmji, kuras vēlētos izmēģināt savā darbā?

Senior
Salmon
30
/206