Post

Replies

Boosts

Views

Activity

Help with a share button swiftUI
I'm trying to creat a share button in my app. I have a list and I want to swipe left any item and appear a button to share the content of the item (exactly like .onDelete but to do other action, share). When I creat this swipeActions, an error appears saying "Result of 'ShareLink<Data ,PreviewImage, PrevieIcon, Label>' Initializer is unused. Here is a print of the App with this code. The button/swipeactions appears there button nothing happens. How can I use the result of this initializer. I'm obviosly new to Swift and I will appreciate any help. I already tryied everething that I found online. import SwiftUI import FirebaseFirestore import FirebaseFirestoreSwift struct ContentView: View {         @State private var showingEditPlaceView = false     @EnvironmentObject var placeVM: PlaceViewModel         @FirestoreQuery(collectionPath: "places", predicates: [.order(by: "name")]) var places: [Place]         @State var search = ""     @ObservedObject var data = getData()         var body: some View {         NavigationView {             List{                 ForEach(places.filter{(self.search.isEmpty ? true :                       $0.name.localizedCaseInsensitiveContains(self.search))}, id: \.id) { place in                  VStack(alignment: .leading) {                       Link(place.name, destination: URL(string: place.link )!)                           .font(.headline)                     }                     .swipeActions(edge: .leading){                         Button{                             ShareLink(item: place.link)                         }                     }                     //ShareLink(item: place.link)                 }
3
0
3.3k
Dec ’22