The Array.first function returns an optional value, because the array could be empty.
You have to unwrap that.
Post
Replies
Boosts
Views
Activity
You have to create the environment object at the top level of your hierarchy and inject it into your topmost view using .environmentObject(yourEnvironmentObject), where yourEnvironmentObject ist the object you created.
See the following article: https://www.hackingwithswift.com/quick-start/swiftui/how-to-use-environmentobject-to-share-data-between-views
You can request and participate in a testflight beta test of Swift Playgrounds 4.2 on developer.apple.com (free developer account seems to be sufficient to participate)
Unfortunately not, ...
but yesterday I heard someone talk about retain cycles in SwiftUI and closures
and now that you ask, this may actually be the problem here: Task's closure retains some values. Try using some weak captures could be the solution.
The view on the right side only displays the current or the latest result of an expression.
To see the output of a print statement you have to open the console in Xcode.
for i in 1...5{
print("\(i) times")
}
You have to keep a strong reference to the Task.
This functionality is now included in the Reality Composer App for iOS/iPadOS. Did you try that?
https://apps.apple.com/de/app/reality-composer/id1462358802
Paul Hudson has a very good video on youtube explaining the details:
https://www.youtube.com/watch?v=EgzWwgRpUuw
You seems to have choosen "new project" instead of "new file"
Did you add NSLocationWhenInUseUsageDescription to your app's plist file?
This category is only meant for discussions about:
Share playground data, manage live views, and control the execution of a playground in Swift Playgrounds using Playground Support.
Wrong topic in Swift Playgrounds and Playground Support! These are for the Swift Development tools.
Without seeing your code we can only speculate:
It could be possible that the size is reported as beeing zero for a short period. Change your code to prevent using a size of zero and see if that solves the problem.
I already reported a similar bug to apple on Jan 9, 2021 – FB8965796. There was never any reaction or fix:
The function Swift.Collection.remove(atOffsets:) is not available in playgrounds