Post

Replies

Boosts

Views

Activity

Reply to What is the best way to align an array of dates with another array.
Correct. Ideally 09/08, 09/09 would match with the appropriate day. Here's a pretty bare bones of the code. Sorry I can't get it formatted right @StateObject var planData = DownloadHansonData() @AppStorage("startDate") var userStartDate: Date = Date() @AppStorage("raceDate") var userRaceDate: Date = Date() @State var startDate = Date() @State var endDate = Date() @State var dateRange: [Date] = [] var body: some View { VStack { // ForEach(dateRange, id: \.self) { day in ScrollView { ForEach(planData.trainingdata) { index in HStack { Text("\(index.day0.day) - \(index.day0.exercise)") Spacer() } HStack { Text("\(index.day1.day) - \(index.day1.exercise)") Spacer() } HStack { Text("\(index.day2.day) - \(index.day2.exercise)") Spacer() } HStack { Text("\(index.day3.day) - \(index.day3.exercise)") Spacer() } HStack { Text("\(index.day4.day) - \(index.day4.exercise)") Spacer() } HStack { Text("\(index.day5.day) - \(index.day5.exercise)") Spacer() } HStack { Text("\(index.day6.day) - \(index.day6.exercise)") Spacer() } // } } .padding() } } }
Sep ’21
Reply to Is it possible to delete an item from Coredata using onTapGesture?
So here's where I'm getting hung up. I created a function in the view and then call removeFavorite, but the compiler fails. @Environment(\.managedObjectContext) var managedObjectContext  @FetchRequest(fetchRequest: FavoriteItem.getAllFavorites()) var favorites:FetchedResults<FavoriteItem>   func removeFavorite(at offsets: IndexSet) {     for item in offsets {       let favorite = favorites[item]       managedObjectContext.delete(favorite)     }   }                    Text("Foo")                     .onTapGesture(perform: removeFavorite)
Nov ’20
Reply to JSON Decoded data not getting returned to be used.
Sorry! I had thought I revealed those. Here they are // MARK: - Welcome struct Welcome: Codable, Identifiable {   let id = UUID()   let reviews: [Review]   let total: Int   let possibleLanguages: [String]   enum CodingKeys: String, CodingKey {     case reviews, total     case possibleLanguages = "possible_languages"   } } // MARK: - Review struct Review: Codable, Identifiable {   let id: String   let url: String   let text: String   let rating: Int   let timeCreated: String   let user: User   enum CodingKeys: String, CodingKey {     case id, url, text, rating     case timeCreated = "time_created"     case user   } } // MARK: - User struct User: Codable {   let id: String   let profileURL: String   let imageURL: String   let name: String   enum CodingKeys: String, CodingKey {     case id     case profileURL = "profile_url"     case imageURL = "image_url"     case name   } }
Oct ’20
Reply to JSON Decoded data not getting returned to be used.
In JSON, dictionary-like structure is called object.  Thank you! I'm learning here so this is helpful. I appreciate your patience as well. I'm sort of struggling to grasp what you're saying. How is this different when a response is [ ] vs { }? In my view I have Welcome declared as @State var yelpbusinessdata: [Welcome] = [] and I'm calling the data as  List(yelpbusinessdata) { review in .. }                .onAppear{                 print("on appear calling data")                 Yelp().getBusinessInfo {                   (yelpbusinessinfo) in                   self.yelpbusinessdata = yelpbusinessinfo                   print("we got yelp reviews")                 }               }
Oct ’20