iOS
protokol SomeProtocol {} func test1_1(hodnota: SomeProtocol) {} func test2_1(hodnota: some SomeProtocol) {} func test1_2(hodnota: any SomeProtocol) {}
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)) } }
Jak funguje systém návrhu mezi UIKit a SwiftUI — dochází k duplicitě komponent nebo obalů?
```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.
Když jsi přišel na projekt, už byl Swift 6, nebo došlo k přechodu během tvé přítomnosti?
Používáte nyní GCD nebo Modern Concurrency (async/await) pro nové úkoly související s vlákny?
```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 } } } ```
Byly problémy s konkurencí (Sendable, unchecked Sendable, přechody mezi aktéry) v modulech, se kterými jste přímo pracoval?
Co se stane, když se do setu předá nil?
@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("Nepodařilo se stáhnout obrázek: \(error)") } } } Button("Stáhnout") { onDownloadPhoto(url) }
Existují v projektu další makra kromě síťové vrstvy?
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())
Stručně se představte a popište svou současnou práci.
Co se používá pro prezentační moduly v UIKit a SwiftUI — jaká architektura?
Pověz mi víc o svém posledním projektu — modulu fotogalerie na Avito, za který jsi odpovídal (krátkodobý pronájem, rezervační formulář atd.)
Byly na poslední WWDC zajímavé sezení nebo rámce, které byste chtěli vyzkoušet v práci?
protokol 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()
Pokud byste navrhovali znovupoužitelnou komponentu tlačítka pro systém návrhu ve SwiftUI s různými styly (primární/sekundární), jak byste to realizovali?
Pokud implementujete novou obrazovku nebo novou funkci, píšete ihned ve SwiftUI, nebo jsou diskuse o volbě mezi UIKit a SwiftUI?
Pověz mi o užitečných Property Wrapper, které jsi použil v projektu