бигзор, ки падар вазифа бошад { бигзор, ки кӯдак вазифа бошад { print("child started, isCancelled = ", Task.isCancelled) // НЕ false for index in (1...[phone]) { print(index) } print("child finished, isCancelled = ", Task.isCancelled) // } await child.value } try? await Task.sleep(nanoseconds: 1_000_000_000) // 1 сония parent.cancel() /////// бигзор, ки падар вазифа бошад { async let child: Void = { print("child started, isCancelled =", Task.isCancelled) for index in (1...[phone]) { print(index) } print("child finished, isCancelled =", Task.isCancelled) }() await child } try? await Task.sleep(nanoseconds: 1_000_000_000) // 1 сония parent.cancel()
iOS
Оё дар модулҳое, ки шумо мустақиман кор мекардед, мушкилоти рақобат (Sendable, unchecked Sendable, гузариш байни актёрҳо) вуҷуд дошт?
протокол SomeProtocol {} функсия test1_1 арзиши: SomeProtocol {} функсия test2_1 арзиши: some SomeProtocol {} функсия test1_2 арзиши: any SomeProtocol {}
Чӣ гуна системаи тарҳрезӣ байни UIKit ва SwiftUI кор мекунад — оё такроршавии компонентҳо ё фароишҳо вуҷуд дорад?
Бихонед бештар дар бораи лоиҳати охирини худ — модулҳои галереи акс дар Авито, ки шумо масъул будед (ишёри кӯтоҳмуддат, формасозии брон, ва ғайра)
протокол SomeProtocol {} func test1_1(қимат: SomeProtocol) {} func test1_2(қимат: any SomeProtocol) {}
Навигатсия дар UIKit навишта шудааст, ва огоҳиномаҳо/шитҳо дар UIKit ё истифода мебаред аз воситаҳои табиии SwiftUI?
протокол SomeProtocol {} функсия test1_1(қиммат: SomeProtocol) {} функсия test1_2(қиммат: ҳар қандай SomeProtocol) {} функсия test2_1(қиммат: some SomeProtocol) {} функсия test2_2<Қиммат: SomeProtocol>(қиммат: Қиммат) {} класа A { функсия test2_2<Қиммат: SomeProtocol>(қиммат: Қиммат) { } } класа B: SomeProtocol { } A().test2_2қиммат(қиммат: B())
Чӣ гуна ҳамкории бо ҳаракатҳо ва зум дар галереяи фото — дар UIKit ё SwiftUI?
бигзор, ки падар бояд Task бошад { let child = Task { print("бача оғоз шуд, isCancelled = ", Task.isCancelled) // for index in (1...[phone]) { print(index) } print("бача тамом шуд, isCancelled = ", Task.isCancelled) // } await child.value } try? await Task.sleep(nanoseconds: 1_000_000_000) // 1 сония parent.cancel()
Дар бораи Property Wrapperҳои муфид, ки дар лоиҳа истифода бурдаед, нақл кунед
Оё дар лоиҳа макросҳои дигар ба ғайр аз қабати шабака ҳастанд?
Чӣ қадар ба шумо кӯмак мерасонанд асбобҳои зеҳни сунъӣ (Cursor, Proxyman ва ғайра) дар баланд бардоштани истеҳсолот дар кор?
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)) } }
struct ExampleView: View { var body: some View { VStack { FormView() Button("Reset") { // TODO: } } } } // ТОЛЫК УХУЧУ 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) } } }
Array { value1 value2 if condition { value3 } }
Кадом версияи забони Swift дар лоиҳа истифода мешавад — аз 6 боло ё поён?
Оё дар WWDC-и охирон сессияҳо/чорчубаҳои ҷолиб буданд, ки мехоҳед дар кор истифода кунед?
```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.
Дар бораи захираҳои ҷолиб барои рушд гап зан — каналҳои YouTube, каналҳои Telegram, ҷомеаҳо, асбобҳо