թող ծնողը լինի Task { թող երեխա լինի Task { 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() /////// թող ծնողը լինի Task { 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 միջև՝ կա՞ կրկնօրինակում կոմպոնենտների կամ պատյանների։
Ավելացրեք ավելի մանրամասն ձեր վերջին նախագծի մասին — լուսանկարների գալերեայի մոդուլը Ավիտոյում, որի պատասխանատուն եք (կարճաժամկետ վարձակալություն, ամրագրման ձևանմուշ և այլն)
Ինչպես իրականացվեց շոշափումների և զույգի փոխազդեցությունը լուսանկարների գալերեայում — UIKit կամ SwiftUI?
պրոտոկոլ SomeProtocol {} func test1_1արժեքը: SomeProtocol) {} func test1_2(արժեքը: any SomeProtocol) {}
պրոտոկոլ 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-ով, և ահազանգերը/շիտերը դուրս եք բերում 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-ների մասին, որոնք օգտագործել ես նախագծում
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) } } }
Կա՞ն այլ մակրոներ նախագծում բացի ցանցային շերտից։
Ի՞նչ չափով են Ձեզ օգնում արհեստական բանականության գործիքները (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)) } }
Ի՞նչ տարբերակ է օգտագործվում Swift լեզվում՝ ավելի բարձր 6-ից կամ ցածր?
Array { value1 value2 if condition { value3 } }
Վերջին 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.
Ի՞նչ է ներկայումս նվազագույն iOS նպատակն նախագծում։