iOS
Коя версия на езика Swift се използва в проекта — по-горе или по-ниско от 6?
@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("Неуспешно изтегляне на изображението: \(error)") } } } Button("Изтегляне") { onDownloadPhoto(url) }
Има ли още макроси в проекта освен мрежовия слой?
Защо текущият код с безкраен цикъл for в main не работи? Как да го поправим?
Какъв е минималният таргет iOS в проекта сега?
Какво се използва за презентационните модули в UIKit и SwiftUI — каква архитектура?
Използвате ли архитектурата Viper за UIKit? Това важи за всички приложения?
Има ли проблеми с конкуренцията (Sendable, unchecked Sendable, преход между актьорите) в модулите, с които работихте директно?
Защо избрахте речник като съхранение на кеша?
Колко ти помагат инструментите за ИИ (Cursor, Proxyman и т.н.) да бъдеш по-продуктивен на работното място?
struct ExampleView: View { @State var isVariant1 = true var body: some View { VStack { Toggle("Използвайте Вариант 1", isOn: $isVariant1.animation(.linear)) Text(isVariant1 ? "Вариант 1" : "Вариант 2") } .padding() } } Вариант1 -> мащаб -> 1 -> 0 Вариант2 -> мащаб -> 0
краен клас 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) } }
Self -> Задача -> (силен) Self .... Обратно -> View desinit -> View model deinit?
Използвате ли в момента GCD или Modern Concurrency (async/await) за нови задачи, свързани с нишки?
```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 } } } ```
Разкажи повече за последния си проект — модула за фотогалерия в Авито, за който отговаряше (краткосрочен наем, форма за резервация и т.н.)
```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.
Имаше ли интересни сесии/рамки на последната WWDC, които бихте искали да опитате да приложите в работата си?
Кога и как се случва отменянето при използване на DispatchQueue с WorkItem и извикване на cancel()?
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)) } }