Hey guys so I have posts which are generated from a JSON codable protocol into a SwiftUI view. In the SwiftUI view there is an share option. I've made it using the following code
Button(action: shareButton){
Image(systemName: "square.and.arrow.up")
.font(.system(size: 22))
.foregroundColor(Color.gray)
.padding(.top, 15)
.padding(.bottom, 20)
.padding(.horizontal, 15)
}
}
It is also linked to a function that does the following.
func shareButton()
{
isShareSheetShowing.toggle()
let url = URL(string: "http://cdn.example.com/item/[id].html")
let av = UIActivityViewController(activityItems: [url!], applicationActivities: nil)
UIApplication.shared.windows.first?.rootViewController?.present(av, animated: true, completion:nil)
}
}
The question I am asking you is as follows. Currently, when you click on share it just shares the link above e.g cdn.something. What I hope to achieve is to share the actual post which is being clicked on not the endpoint. I tried adding (post.id) into the URL but it doesent recognize it ( it doesent go green it just stays orange and considers it a part of the URL )
Help would be greatly appreciated. Thank you guys!