It seems like you can read the download progress from the NSMetadataUbiquitousItemPercentDownloadedKey file metadata key.
You could probably initialize an NSMetadataItem using a URL object, then use the value(forAttribute:) function to fetch the download progress from 0.0 to 1.0.
NSMetadataUbiquitousItemPercentDownloadedKey: https://developer.apple.com/documentation/foundation/nsmetadataubiquitousitempercentdownloadedkey
NSMetadataItem: https://developer.apple.com/documentation/foundation/nsmetadataitem
Post
Replies
Boosts
Views
Activity
Just an update: If you are using the #Predicate macro in any part of your SwiftUI's body, move it out to its own function and call the function from within your body. That seems to have fixed it for me.
e.g. Instead of:
var body: some View {
HStack {
...
let predicate = #Predicate<Item> { ... }
...
}
}
Do:
var body: some View {
HStack {
...
findItems()
...
}
}
func findItems() {
let predicate = #Predicate<Item> { ... }
...
}
Seeing this too for a project that uses SwiftData (unsure if related).
It might be worth noting that it does not affect building for running, only archiving.
Running in the iOS Simulator and a real device works, but archiving will throw the 'file name too long' error.
You might want to try something like this:
@Model
final class Note {
var name: String
var item: Item?
init(name: String = "Note name") {
self.name = name
}
// Move this out of init
func setItem(_ item: Item) {
self.item = item
}
}
And call setItem after init. I had some luck with this when I tried to initialize another Model in a Model too.
Having the same issue here for my app.
The unfortunate thing is that the timer starts counting up (mine works like a countdown), which makes it incredibly confusing for the user.
As a workaround, I have to put the time the countdown ends.
Using an if conditional (check if the date < current date) doesn't work as well. Seems like the UI is only updated once.
Seems like there's no reliable way to do it now other than through a server-side push notification...