protocol SomeProtocol {} func test1_1(value: SomeProtocol) {} func test1_2(value: any SomeProtocol) {}
struct ExampleView: View { var body: some View { VStack { FormView() Button("Reset") { // TODO: } } } } // READ ONLY struct FormView: View { @State private var firstname = "" @State private var lastname = "" @State private var email = "" @State private var website = "" var body: some View { Form { TextField("Enter firstname", text: self.$firstname) TextField("Enter lastname", text: self.$lastname) TextField("Enter email address", text: self.$email) TextField("Enter website address", text: self.$website) } } }
If you use DispatchQueue with WorkItem and call cancel() — when and how does the cancellation occur?
Tell about useful Property Wrappers you've used in a project.
Were there interesting sessions/frameworks at the last WWDC that you would like to try applying in your work?
final class ProfileViewModel1 { enum State { ... } var state: State = .idle let service: UserService init(service: UserService) { ... } func onBackPress() { // view deinit } func loadUser() { state = .loading Task { [weak self] guard let self else { return } do { let user = try await self.service.fetchUser() self.state = .loaded(user) } catch { self.state = .failed(error.localizedDescription) } } } }
Tell me more about your last project — the photo gallery module in Avito, which you were responsible for (short-term rental, booking form, etc.)
How do you understand the term 'structured concurrency' in Swift? Does Task.detached fit this concept?
Self -> Task -> (strong) Self .... Back -> View desinit -> View model deinit?
// Writes `data` to a file named `file`. func writeData(_ data: Data, to file: String) { let documentDirectoryURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first! let fileURL = documentDirectoryURL.appendingPathComponent(file) try? data.write(to: fileURL) } // Removes file named `file`. func remove(file: String) { let documentDirectoryURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first! let fileURL = documentDirectoryURL.appendingPathComponent(file) try? FileManager.default.removeItem(at: fileURL) } // Reads `Data` from a file named `file`. If the file doesn't exists returns `nil`. func readData(from file: String) -> Data? { let documentDirectoryURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first! let fileURL = documentDirectoryURL.appendingPathComponent(file) return try? Data(contentsOf: fileURL) } final class DiskCache<T>: CacheProtocol { func setValue(_ value: T?, forKey key: String) { } func getValue(forKey key: String) -> T? { } func fetchValue(forKey key: String, completion: @escaping (T?) -> Void) { } }
Briefly introduce yourself and describe your current work.
What happens when nil is passed to set?
import UIKit protocol CacheProtocol { associatedtype Value func setValue(_ value: Value?, forKey key: String) func value(forKey key: String) -> Value? func fetchValue(forKey key: String, completion: @escaping (Value?) -> Void) }
Why did you choose a dictionary as the cache storage?
Why did the UI render correctly before adding an explicit main-thread dispatch?
Why did you create separate load and getLastCities methods, and what should happen if getLastCities is called before data has been loaded?
Why use final class instead of class for the cache implementation?
How would you prioritize the identified issues if the project must go to production in one hour?