Post

Replies

Boosts

Views

Activity

Reply to Keep face up the cards if equal
Creating a card game with turning cards and everything needed is shown in length in the free cs193p video series from stanford university. Unfortunately I can't link it here, but a search for „cs193p“ in google gives the correct result.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’22
Reply to Where is Playgrounds 4? It's 2021-12-14 now...
Yesterday Apple updated its iPadOS 15 web page: For „Universal Control“ they added a badge saying that it was delayed to spring 2022. For Swift Playgrounds they removed a footnote stating it would come „late 2021“. So there is still hope we will see it before the holidays. My children and I are also waiting for it to be released and would be very disappointed if it was delayed even more. Come on Apple, you can do it!
Dec ’21
Reply to How can I fix this leaking memory?
Did you try: init() { timer = Timer.scheduledTimer(withTimeInterval: 0.1, repeats: true) { [weak self] timer in self?.getRandonNumber() } } Capturing self is alway „dangerous“ and can lead to memory leaks. The timer/closure keeps a reference to the ViewModel and the ViewModel keeps a reference to the timer, therefore their memory is never released. I don't know if your ViewModel is recreated many times during the run of your app, but if it where, this reference cycle would lead to a memory leak.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’21
Reply to Async in Playground
Like with every async function called from a synchronous context (the global context of your playground) you have to wrap your call to doStuff() in an async block and await it: async{ await doStuff() } This is expected to change to Task.async{ await doStuff() } in a later beta. The following list of WWDC videos covering Swift concurrency should provide further background: Meet Swift Concurrency
Jun ’21
Reply to Keep face up the cards if equal
Creating a card game with turning cards and everything needed is shown in length in the free cs193p video series from stanford university. Unfortunately I can't link it here, but a search for „cs193p“ in google gives the correct result.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to Async and Await code doesn't work on command line tools but works on Xcode playgrounds
You have to define a main function marked with the @main attribute containing your Task. Playgrounds are special in a way that they run all top level code automatically, normal swift programs don't do that.
Replies
Boosts
Views
Activity
Dec ’21
Reply to Where is Playgrounds 4? It's 2021-12-14 now...
Yesterday Apple updated its iPadOS 15 web page: For „Universal Control“ they added a badge saying that it was delayed to spring 2022. For Swift Playgrounds they removed a footnote stating it would come „late 2021“. So there is still hope we will see it before the holidays. My children and I are also waiting for it to be released and would be very disappointed if it was delayed even more. Come on Apple, you can do it!
Replies
Boosts
Views
Activity
Dec ’21
Reply to Function Issue: Closure containing a declaration cannot be used with result builder 'ViewBuilder'
The swift compiler's error message is misleading, but what happens if you write presentationMode instead of presentatoinMode ?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’21
Reply to How does one access a file inside of a XCTestCase class?
let bundle = Bundle(for: TheNameOfYourXCTestCaseSubClass.self) Using the class name of your XCTestCase-derived class the above code gives you the corresponding Bundle. Afterwards use the methods on Bundle to access the specific file.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to Accessing an environmentObject's function in another environmentObject which is created at the same time
I'm not sure, if it is intended by Apple or even allowed to use @EnvironmentObject inside the model code. I think you should declare billModel in PDFManger as a simple let or var and set it yourself using an initializer:
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Hey Apple or developers..About ipad swift playground!
I think you declared your Property wrapper outside of a view struct (like on the to level of the Playground code) which is not supported.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to Table - unable to use more than 10 columns
I would suspect it has to do with the same limitation all of SwiftUI suffers: You can only declare 10 subviews inside of a view. The usual workaround is to use Group{} like this: HStack{ Group{ Item1 Item2 ... Item10 } Group{ Item11 ... Item 20 } }
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to SwiftUI EnvironmentObject and Alert Failure
Did you try .sheet(isPresented: $showTest) {             FailingView().environmentObject(stateObj)  }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to How can I fix this leaking memory?
I can't see anything really broken about your code. Only .environmentObject(vm) in the body of ContentView is not necessary.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to How can I fix this leaking memory?
Did you try: init() { timer = Timer.scheduledTimer(withTimeInterval: 0.1, repeats: true) { [weak self] timer in self?.getRandonNumber() } } Capturing self is alway „dangerous“ and can lead to memory leaks. The timer/closure keeps a reference to the ViewModel and the ViewModel keeps a reference to the timer, therefore their memory is never released. I don't know if your ViewModel is recreated many times during the run of your app, but if it where, this reference cycle would lead to a memory leak.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to SwiftUI MagnificationGesture broken in iPadOS 15?
Interesting! Unfortunately this is does not give the same result, depending on the views content. Try Circle().stroke() for example, to see the difference in rendering.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to How do I get Swift Playgrounds 4 beta on iPadOS 15?
PS: is it supported on iPad Air 2 to begin with? Playgrounds 4 will run on all devices capable of running iOS 15 and will be available later this year, was the information given at WWDC.
Replies
Boosts
Views
Activity
Jul ’21
Reply to Async in Playground
Sorry, I forgot about three additional things you have to do to use Swift concurrency in Playgrounds: import _Concurrency import PlaygroundSupport PlaygroundPage.current.needsIndefiniteExecution = true
Replies
Boosts
Views
Activity
Jun ’21
Reply to Async in Playground
Like with every async function called from a synchronous context (the global context of your playground) you have to wrap your call to doStuff() in an async block and await it: async{ await doStuff() } This is expected to change to Task.async{ await doStuff() } in a later beta. The following list of WWDC videos covering Swift concurrency should provide further background: Meet Swift Concurrency
Replies
Boosts
Views
Activity
Jun ’21