Post

Replies

Boosts

Views

Activity

Reply to New ShareLink with custom type is not working
You will need to check that the value in the url property is a genuine URL I used nil coalescing to provide a default URL URL(fileURLWithPath: "/dev/null"), but every time I tried to use the Sharesheet, nothing happens and the debug area shows this error: [ShareSheet] cancelled request - error: The operation couldn’t be completed. Invalid argument. Sharing finished with error: Error Domain=NSPOSIXErrorDomain Code=22 "Invalid argument" at SwiftUI/SharingActivityPickerBridge.swift:266 So I think the main issue is that, for whatever reason the URL is nil and I can't understand why because in the Recoding model the url is not even optional. The only thing I can think right now is that the URL is a String instead of URL (that's why I need to use URL(string:) in the SentTransferredFile part, to convert the string into an URL) and maybe this is the problem with the optional. Any idea? Many thanks!
Sep ’22
Reply to New ShareLink with custom type is not working
Thanks for the response! I updated the code to the initializer with the preview parameter and now the code compile but I have a problem with this unwrap URL: SentTransferredFile(URL(string: audio.url)!) And since the url is a String, I have to use URL(string), is there any way to deal with this optional? I was watching this session from the WWDC22, minute 9:14, and here they use another approach: static var transferRepresentation: some TransferRepresentation { FileRepresentation(contentType: .mpeg4Movie) { SentTransferredFile($0.file) } importing: { received in let destination = try Self.copyVideoFile(source: received.file) return Self.init(file: destination) } } This makes sense but when I apply it in my own code I have problems with the line return Self.init(file: destination), since in my case I have an entity called Recording, without any variable called "File", but if I understand correctly, I must associate destination to Recording.url, is this correct?
Sep ’22