iOS
Vai izmantojat Viper arhitektūru UIKit? Vai tas attiecas uz visas lietojumprogrammas?
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 {}
Vai šobrīd izmantojat GCD vai Modern Concurrency (async/await) jauniem uzdevumiem, kas saistīti ar pavedieniem?
protokols SomeProtocol {} func test1_1(vērtība: SomeProtocol) {} func test1_2(vērtība: any SomeProtocol) {}
Kā View un ViewModel sazinās UIKit — vai tiek izmantots kaut kas līdzīgs RxSwift/Combine saistībām?
```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)) } } ```
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.
```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 } } } ```
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)) } }
Kad un kā notiek atcelšana, izmantojot DispatchQueue ar WorkItem un izsaucot cancel()?
Self -> Uzdevums -> (spēcīgs) Self .... Atpakaļ -> View desinit -> View model deinit?
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())
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?
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?
Kas tiek izmantojams prezentācijas moduļiem UIKit un SwiftUI — kāda arhitektūra?
@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) }
Īsi iepazīstiniet sevi un aprakstiet savu pašreizējo darbu.
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.)
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()
Vai pēdējā WWDC bija interesantas sesijas/rāmji, kuras vēlētos izmēģināt savā darbā?