iOS
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)) } }
Set'e nil geçirildiğinde ne olur?
protokol SomeProtocol {} func test1_1(değer: SomeProtocol) {} func test1_2(değer: any SomeProtocol) {}
```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)) } } ``` Görünüşe göre amaç, SwiftUI'da bir düğme stilini özelleştirmek ve padding, ön plan rengi, çerçeve genişliği, arka plan rengi ve kırpma şekli gibi farklı modifikasyonlar denemektir. Muhtemelen soru, istenen görünüm veya davranışı elde etmek için düğme stilini düzeltmek veya geliştirmekle ilgilidir; örneğin, düğmenin kullanılabilir genişliği kadar geniş olmasını sağlamak veya görsel stilini ayarlamak gibi.
Şu anda iş parçacıklarıyla ilgili yeni görevler için GCD veya Modern Concurrency (async/await) kullanıyor musunuz?
Projeye geldiğinde Swift 6 zaten vardı mı, yoksa geçiş senin zamanında mı gerçekleşti?
```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 } } } ```
protokol SomeProtocol { func test() } func test1_1(değer: SomeProtocol) {} func test1_2(değer: any SomeProtocol) {} func test2_1(değer: some SomeProtocol) {} func test2_2<Değer: SomeProtocol>(değer: Değer) {} class A { func test2_2<Değer: SomeProtocol>(değer: Değer) { } } class B: SomeProtocol { func test() {} } class C: B {} A().test2_2(değer: B())
Doğrudan çalıştığınız modüllerde eşzamanlılık sorunları (Sendable, unchecked Sendable, aktörler arasındaki geçişler) yaşandı mı?
UIKit ve SwiftUI'da sunum modülleri için ne kullanılır — hangi mimari?
DispatchQueue ile WorkItem kullanıp cancel() çağrıldığında iptal ne zaman ve nasıl gerçekleşir?
@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("Resim indirilirken hata: \(error)") } } } Button("İndir") { onDownloadPhoto(url) }
son sınıf 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) } }
SwiftUI'da farklı stiller (birincil/ikincil) olan bir tasarım sistemi için yeniden kullanılabilir bir düğme bileşeni tasarlıyorsanız, bunu nasıl gerçekleştirirdiniz?
Projede ağ katmanı dışında başka makrolar var mı?
Kendinizi kısaca tanıtın ve mevcut işinizi anlatın.
Son WWDC'de ilginç oturumlar/çerçeveler oldu mu ve bunları işinizde denemek ister misiniz?
Projede SwiftUI kullanımı hakkında bana bilgi ver — politika nedir, kaç ekran SwiftUI ile yazılmış?
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()
Yeni bir ekran veya yeni bir özellik uygularken, hemen SwiftUI mı yazıyorsunuz, yoksa UIKit ve SwiftUI arasında seçim konusunda tartışmalar oluyor mu?