Post

Replies

Boosts

Views

Activity

SwiftData one-to-many Relationship not working
Hello, I have the problem that my todos are not only assigned to one project (one-to-many). They are displayed in the same way in every project. What have I done wrong? Die HauptApp: import SwiftData @main struct consiliaApp: App { var body: some Scene { WindowGroup { ProjektView() }.modelContainer(for: Projekte.self) } } Das Datenmodell: import SwiftData @Model final class Projekte { var name: String var info: String var startdate: Date var enddate: Date var startadresse: String var zieladresse: String var priority: Int @Relationship(deleteRule: .cascade, inverse: \Todo.projekte) var todos: [Todo]? = [] init(name: String, info: String, startdate: Date, enddate: Date, startadresse: String, zieladresse: String, priority: Int) { self.name = name self.info = info self.startdate = startdate self.enddate = enddate self.startadresse = startadresse self.zieladresse = zieladresse self.priority = priority } } @Model class Todo { var name: String // @Relationship var projekte: Projekte? init(name: String, projekte: Projekte) { self.name = name self.projekte = projekte } } So speichere ich die Projekte: let newDaten = Projekte(name: name, info: info, startdate: stardate, enddate: enddate, startadresse: startadresse, zieladresse: zieladresse, priority: priority) modelContext.insert(newDaten) newDaten.todos = [] Das ist der TodoAddView: import SwiftData struct TodoAddView: View { @Environment(\.modelContext) private var modelContext @Environment(\.dismiss) var dismiss var projekte: Projekte @State private var name: String = "" var body: some View { NavigationView { Form { Section(header: Text("Name")) { TextField("Name eingeben", text: $name) } } .navigationBarTitle("Aufgabe hinzufügen", displayMode: .inline) .navigationBarItems(leading: Button("Abbrechen"){ dismiss() }.foregroundStyle(.red), trailing: Button("Fertig") { // Hier Code zum Speichern der Daten let newDaten = Todo(name: name, projekte: projekte) modelContext.insert(newDaten) newDaten.projekte = projekte projekte.todos?.append(newDaten) dismiss() }) } } } Thanks and a nice Weekend!
0
0
542
Jan ’24
Text output of the text based on a lab from a CoreMLDataModel
Hello, I have created a data model with Text Classification which contains many garments with the label clothing, technology equipment with the label technology, etc.... . I have inserted it so that when entering for example "T-shirt" the label clothing is output. But I want it so that when I create an equipment category with the clothing, that it suggests me clothing items, which I add. How do I implement this. In the function you can only use"preditction.label". I program with SwiftUI. func textml() {         do {             let model = try DataModel_Symbols_Consilia(configuration: .init())             let prediction = try model.prediction(text: addProjectVM.title)             addProjectVM.symbol = prediction.label         } catch {             modelOutput = "Something went wrong"         }     } Greetings Janik
3
0
1.2k
Mar ’23
CoreData always takes the same item
I have the problem that when I want to edit the item, the item that was created last is always changed. //  EditSheet.swift //  CoreData_T // //  Created by Janik Hartmann on 11.01.23. // import SwiftUI import Foundation import CoreData struct EditSheet: View {     @Environment(\.managedObjectContext) private var viewContext     @Environment(\.dismiss) private var dismiss          @State private var name: String = ""     private var item: Item     var itemid: UUID              init(itemId: UUID, item: Item) {                 self.item = item                 self.itemid = item.id!                 self.name = item.name ?? ""             }              var body: some View {         VStack{             TextField("Text eingeben", text: $name)                 .padding()             Button {                                  update(item: item, itemid: item.id!)                 dismiss()                                               } label: {                 Text("Save")             }.padding()         }.onAppear{             name = item.name!                      }     }     func update(item:Item, itemid id: UUID){         let fetchRequest = NSFetchRequest<NSManagedObject>(entityName: "Item")         fetchRequest.predicate = NSPredicate(format: "id = %@", itemid as CVarArg)                  do {             let results = try viewContext.fetch(fetchRequest) // Rufe den Fetchrequest auf             let objectToUpdate = results[0] // Nehme das erste             objectToUpdate.setValue(name, forKey: "name") //Editiere den Key "name" zum übergebenen Wert             do {                 try viewContext.save() // Speichern                 print("Erfolgreich gespeichert!")             } catch let error as NSError {                 print("Fehler beim Speichern. \(error), \(error.userInfo)")             }         } catch let error as NSError {             print("Fehler beim Fetchen. \(error), \(error.userInfo)")         }     } }
17
0
1.8k
Jan ’23
CoreData takes random id's when editing.
I have defined an attribute "id" as UUID in the database. When I want to edit an item, I want it to choose the right item based on the id. But when I edit an item it chooses a random item from the list. I've used a print statement to print the id each time and therefore I've seen that it randomly selects an id and not from the selected item. import SwiftUI import CoreData import Foundation struct ContentView: View {     @Environment(\.managedObjectContext) private var viewContext     //Abfrage zum Anzeigen     @FetchRequest(sortDescriptors: [NSSortDescriptor(keyPath: \Item.timestamp, ascending: true)],                   animation: .default)          //Referenz zum Entity Item     var items: FetchedResults<Item>          @State private var name: String = ""      //     Test     @State private var editName = ""     @State private var showEditInput = false          var body: some View {         NavigationView {             VStack{                 TextField("Text eingeben", text: $name)                     .padding()                 Button {                                          addItem()                                      } label: {                     Text("Save")                 }.padding()                 List {                     ForEach(items, id: \.self) { item in                                                  NavigationLink(destination: ToDo(list:item)) {                             HStack {                                 Text(item.name ?? "Not found")                                 Button {                                     self.showEditInput = true                                 } label: {                                     Text("Edit")                                 }.buttonStyle(.bordered)                             }.alert("Editieren", isPresented: $showEditInput, actions: {                                 // Eingabe des neuen Namens                                 TextField("Neuer Listenname", text: $editName)                                                                  Button("Save", action: {                                     editItem(itemid: item.id!, newName: editName) // Rufe die Edit funktion auf //                                    self.editName = "" //Resete den Eingabenstring                                 })                                                                  Button("Cancel", role: .cancel, action: { //                                    self.editName = "" // Resete den Eingabenstring                                 })                             }, message: {                                 Text("Neuen Namen eingeben")                             })                                                                                   }                                           }                     .onDelete(perform: deleteItems)                 }             }             }                   }      //MARK: - Hinzufügen der Listen     private func addItem() {         withAnimation {             let newItem = Item(context: viewContext)             newItem.name = name             newItem.id = UUID()             do {                 try viewContext.save()             } catch {                 // Replace this implementation with code to handle the error appropriately.                 // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.                 let nsError = error as NSError                 fatalError("Unresolved error \(nsError), \(nsError.userInfo)")             }         }     }          private func editItem(itemid id: UUID, newName: String) {         // Fetchrequest um anhand der ID das richtige Item ausfindig zu machen         let fetchRequest = NSFetchRequest<NSManagedObject>(entityName: "Item")         fetchRequest.predicate = NSPredicate(format: "id == %@", id as CVarArg)                  do {             let results = try viewContext.fetch(fetchRequest) // Rufe den Fetchrequest auf             let objectToUpdate = results[0] // Nehme das erste             objectToUpdate.setValue(newName, forKey: "name") //Editiere den Key "name" zum übergebenen Wert             print(id)             do {                 try viewContext.save() // Speichern                 print("Erfolgreich gespeichert!")             } catch let error as NSError {                 print("Fehler beim Speichern. \(error), \(error.userInfo)")             }         } catch let error as NSError {             print("Fehler beim Fetchen. \(error), \(error.userInfo)")         }                       }     private func deleteItems(offsets: IndexSet) {         withAnimation {             offsets.map { items[$0] }.forEach(viewContext.delete)             do {                 try viewContext.save()             } catch {                 // Replace this implementation with code to handle the error appropriately.                 // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.                 let nsError = error as NSError                 fatalError("Unresolved error \(nsError), \(nsError.userInfo)")             }         }     } }
3
0
791
Jan ’23
Update of existing items with CoreData in SwiftUI
Hello I have the problem that I can not update items that have already been saved with CoreData. I have tried different ways, but each time came several different error messages. In addition, many instructions are very old or use UIKit. I think I always think of the wrong approach. Do you know one or more ways how I can update existing items? I'll send a code along, though I've removed my attempts for now. So maybe you can give me some approaches based on my code. Thanks in advance! The ItemView: import SwiftUI import Foundation import CoreData struct ToDo: View {          @Environment(\.managedObjectContext) private var viewContext          // Referenz zu Entitiy Item     @ObservedObject var list: Item          //Die Todos mit Referenz zum Array vom Entity ToDos     @State var liste: [ToDos]          @State private var showingNewToDo = false          //Die Funktionen der Store-Klasse     var store = Store()          @State private var todo: String = ""              // Konstruktor-Hack, um die Verwendung     // von ToDos als Status zu ermöglichen (damit die     // Liste aktualisiert wird)     init(list: Item){         self.list = list         self.liste = list.liste?.array as! [ToDos]     }               var body: some View {                  NavigationView {                              List {                     //Zeigt jedes ToDo für die Liste                     ForEach(liste.sorted(using: SortDescriptor(\ToDos.todo))) { todo in                                                      Text(todo.todo ?? "Not found")                                              }                     .onDelete(perform: deleteItems)                 }                      }.toolbar {             EditButton()                          Button() {                 showingNewToDo.toggle()             } label: {                 Label("Hinzufügen", systemImage: "plus")             }         }         .sheet(isPresented: $showingNewToDo){             ToDoAddSheet() { todo in                                  //speichert Änderungen                 list.addToListe(todo)                 store.save(viewContext: viewContext)                                  //Fügt ToDos zu Listen hinzu                 withAnimation{                     liste.append(todo)                 }             }         }     }          //Wird hier nicht benötigt, würde aber Daten speichern     private func addItem() {         withAnimation {             let newToDo = ToDos(context: viewContext)             newToDo.id = UUID()             newToDo.todo = todo                                               do {                 try viewContext.save()             } catch {                 // Replace this implementation with code to handle the error appropriately.                 // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.                 let nsError = error as NSError                 fatalError("Unresolved error \(nsError), \(nsError.userInfo)")             }         }     }     private func deleteItems(offsets: IndexSet) {         withAnimation {             offsets.map { liste[$0] }.forEach(viewContext.delete)             liste.remove(atOffsets: offsets)             store.save(viewContext: viewContext)             do {                 try viewContext.save()             } catch {                 // Replace this implementation with code to handle the error appropriately.                 // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.                 let nsError = error as NSError                 fatalError("Unresolved error \(nsError), \(nsError.userInfo)")             }         }     }      } The AddView: import SwiftUI struct ToDoAddSheet: View {          @Environment(\.dismiss) private var dismiss     @Environment(\.managedObjectContext) private var viewContext          var store = Store()     var save: (ToDos) -> ()                    @State private var todo: String = ""          var body: some View {                 VStack{             TextField("Text eingeben", text: $todo)                 .padding()             Button {                 add()                 dismiss()             } label: {                 Text("Save")             }.padding()         }     }               //MARK: - Syntax für neue todos     private func add() {         let newToDo = ToDos(context: viewContext)         newToDo.todo = todo         newToDo.id = UUID()         save(newToDo)              } }
0
0
900
Jan ’23
Core-Data one-to-many relationship
Hello, I have the problem that I want to create a relationship between a list and its items. I have created relationships and also selected one-to-many for the list. But when I create multiple lists and add an item in the list, this item is added to each list and not only to the one. How can I set that the item is only added to the list that was selected? Lists code import SwiftUI import CoreData import Foundation struct ContentView: View {     @Environment(\.managedObjectContext) private var viewContext     @FetchRequest(sortDescriptors: []) var items: FetchedResults<Item>          @State private var name: String = ""     var body: some View {         NavigationView {             VStack{                 TextField("Text eingeben", text: $name)                     .padding()                 Button {                                          addItem()                                      } label: {                     Text("Save")                 }.padding()                 List {                     ForEach(items, id: \.self) { item in                                                  NavigationLink(destination: ToDo()) {                             Text(item.name ?? "Not found")                         }                      //   Text(item.name ?? "Not found")                     }                     .onDelete(perform: deleteItems)                 }             }             }                   }          private func addItem() {         withAnimation {             let newItem = Item(context: viewContext)             newItem.name = name             newItem.id = UUID()             do {                 try viewContext.save()             } catch {                               let nsError = error as NSError                 fatalError("Unresolved error \(nsError), \(nsError.userInfo)")             }         }     }     private func deleteItems(offsets: IndexSet) {         withAnimation {             offsets.map { items[$0] }.forEach(viewContext.delete)             do {                 try viewContext.save()             } catch {                                 let nsError = error as NSError                 fatalError("Unresolved error \(nsError), \(nsError.userInfo)")             }         }     } } struct ContentView_Previews: PreviewProvider {     static var previews: some View {         ContentView().environment(\.managedObjectContext, PersistenceController.preview.container.viewContext)     } } items list import SwiftUI import Foundation import CoreData struct ToDo: View {          @Environment(\.managedObjectContext) private var viewContext          @FetchRequest(sortDescriptors: []) var todos: FetchedResults<ToDos>              @State private var todo: String = ""     var body: some View {                  NavigationView {             VStack{                 TextField("Text eingeben", text: $todo)                     .padding()                 Button {                                          addItem()                                      } label: {                     Text("Save")                 }.padding()                 List {                     ForEach(todos, id: \.self) { todos in                                                      Text(todos.todo ?? "Not found")                                              }                     .onDelete(perform: deleteItems)                 }             }         }              }          private func addItem() {         withAnimation {             let newToDo = ToDos(context: viewContext)             newToDo.todo = todo             newToDo.id = UUID()             do {                 try viewContext.save()             } catch {                                 let nsError = error as NSError                 fatalError("Unresolved error \(nsError), \(nsError.userInfo)")             }         }     }     private func deleteItems(offsets: IndexSet) {         withAnimation {             offsets.map { todos[$0] }.forEach(viewContext.delete)             do {                 try viewContext.save()             } catch {                                 let nsError = error as NSError                 fatalError("Unresolved error \(nsError), \(nsError.userInfo)")             }         }     }      } struct ToDo_Previews: PreviewProvider {     static var previews: some View {         ToDo()     } } Thank you!
2
0
1.3k
Jan ’23
'App' is ambiguous for type lookup in this context
I get these errors every time: 'App' is ambiguous for type lookup in this context And: Cannot convert value of type 'HomeList.Type' to expected argument type 'ObservedResults' This is the code: import UserNotifications import RealmSwift @main struct KamelApp: App {     @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate    // @StateObject private var itemId = ObjectId()     let migrator = Migrator()     var body: some Scene {         WindowGroup {             let _ = UserDefaults.standard.set(false, forKey: "_UIConstraintBasedLayoutLogUnsatisfiable")             let _ = print(FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!.path)                  ContentView(homeLists: HomeList, itemId: ObjectId())         }     } } The second error comes from Contentview
1
0
1.4k
Dec ’22
Operator function '<' requires that 'Date' conform to 'StringProtocol'
Hi. I would like to add an if statement to my list that only shows items that are only seven days in the future from the current date, and 30 days in the future. This is how tasks should be sorted. So upcoming tasks in the next 7 days and as an extra list tasks in the next 30 days. But I always get this error ("Operator function '<' requires that 'Date' conform to 'StringProtocol'"), or is there another way to sort the list like this? List {                 Section(header: Text("Test1")){                      ForEach(homeLists, id: \.id) { homeList in                           if homeList.listdate < Date.now {                               NavigationLink {                               HomeTabView(homeList: homeList)                                 } label: { The content of the list is then written in the label underneath.
2
0
1.7k
Nov ’22
SwiftUI toolbar not showing on a Tabview
I have the problem that I want to add a button with "Toolbaritem". This should be placed as "Add" button on the top right. But unfortunately this button is not displayed. import SwiftUI import RealmSwift struct HomeListItems: View {     @ObservedRealmObject var homeList: HomeList     @State private var isPresented: Bool = false     @State private var selectedItemIds: [ObjectId] = []     var body: some View {         VStack {             if homeList.items.isEmpty {                 Text("Keine ToDo's gefunden")             }             List {                 ForEach(homeList.items) { item in                     NavigationLink {                         AddToDoItems(homeList: homeList, itemToEdit: item)                     } label: {                         ItemCell(item: item, selected:                                     selectedItemIds.contains(item.id)) { selected in   if selected {   selectedItemIds.append(item.id)                                 if let indexToDelete = homeList.items.firstIndex(where: {                                     $0.id == item.id }) {                                     // delete the item                                              $homeList.items.remove(at: indexToDelete)                                 }                             }                         }                     }                 }             }             .navigationTitle(homeList.title)         }.toolbar{             Button {                 //action                 isPresented = true             } label: {                 Image(systemName: "plus")             }}         .sheet(isPresented: $isPresented) {             AddToDoItems(homeList: homeList)         }     } } struct HomeListItems_Previews: PreviewProvider {     static var previews: some View {         HomeListItems(homeList: HomeList())     } }
2
0
2.0k
Oct ’22
Navigation View large distance to the top
Hello, I have the problem that a navigation view with a shape has a high distance to the top (see picture). How can I reduce this so that it looks "normal". The Code looks like this: struct EinstellungsView: View {     @ObservedObject var userSettings = UserSettings()     @State var darkMode = false;          var body: some View {                  NavigationView {                 Form {                     Section(header: Text("PROFILE")) {                         TextField("Anzeigename", text: $userSettings.username)                         Toggle(isOn: $darkMode) {                             Text("Darkmode")                         }                     }                                          Section(header: Text("Währungen")){                         Picker(selection: $userSettings.currencyBase, label: Text("Währungsbasis")){                             ForEach(userSettings.currencyOptions, id: \.self) { währungen in                                 Text(währungen)                             }                         }                         Toggle(isOn: $userSettings.currencyFormat) {                                             Text("Alt. Währungsformatierung")                         }                     }                 }                 .navigationBarTitle("Settings")         }     } }
2
0
771
Sep ’22
Images with names stored in an array are not displayed.
Hello. wants to display images in a TabView. The names of the images are stored in an array, because there is more than one image. But in the final preview only a gray field is visible. What do I have to do so that the images are displayed? The ImageSlider import SwiftUI struct ImageSlider: View {        //var numberOfImages = 4     let  countryItem : CountryItem     var body: some View {         GeometryReader { proxy in                          TabView{                 ForEach(0..<4) { num in                     Image("\(countryItem.image)")                         .resizable()                         .scaledToFill()                         .overlay(Color.black.opacity(0.1))                         .tag(num)                                      }             }.tabViewStyle(PageTabViewStyle())                 .clipShape(RoundedRectangle(cornerRadius: 5))                 .padding()                 .frame(width: proxy.size.width, height: proxy.size.width / 1.5 )         }} } The Array with the datas. The images named 0,1,2,3 and 4,5,6,7 import Foundation // Bitte Ab sofott hier neue Länder einfügen! class CountryItemHolder: ObservableObject{          public let countryList: [CountryItem] = [                  CountryItem(             country_flag: "🇪🇬",             name: "Ägypten",             description: "Ägypten ist ein Land, das Nordostafrika mit dem Nahen Osten verbindet und bis in die Zeit der Pharaonen zurückreicht. Zu den jahrtausendealten Baudenkmälern im fruchtbaren Niltal zählen die kolossalen Pyramiden und die Große Sphinx von Gizeh sowie die hieroglyphenbedeckten Wände des Karnak-Tempels und die Gräber im Tal der Könige bei Luxor.",             hauptstadt: "Kairo",             währung: "Ägyptisches Pfund",             währungskürzel: "egp",             einwohnerzahl: "102,3 Millionen",             nicetoknow:"In den meisten touristischen Orten werden Kreditkarten als Zahlungsmittel akzeptiert. Zudem gibt es mehrere Bankautomaten. Das Telefonnetz ist gut ausgebaut. Das Äygptische Stromnetz läuft mit 220V und es wird üblicherweiße der Eurostecker verwendet.",             image: [0,1,2,3]),         CountryItem(             country_flag: "🇦🇹",           name: "Österreich",           description: "Österreich ist ein mitteleuropäischer Binnenstaat. Mehr als 62 Prozent seiner Staatsfläche werden von alpinem Hochgebirge gebildet. Der österreichische Staat wird deshalb auch als Alpenrepublik bezeichnet.",             hauptstadt: "Wien",             währung: "Euro",             währungskürzel: "eur",             einwohnerzahl: "8,917 Millionen",             nicetoknow:"Österreich ist ein EU-Mitgliedsstaat. Österreich verlangt Mautgebühren für ihre Autobahnen.",             image:[4,5,6,7]), ] }
8
0
1k
Sep ’22
Cannot convert value of type '[Int]' to expected argument type 'Int'
Hi. I have created a "struct" with items and given in an array to each item the content. I want to provide some info for each country. That's why in the "struct" are items like name, capital or image. I wanted to make a slider with images and so I tried to make another array in the array at image. Then I get this error message. I hope you can help me. Die struct mit den items: import Foundation struct CountryItem: Identifiable {     let id = UUID()     let country_flag: String     let name: String     let description: String     let hauptstadt: String     let währung: String     let währungskürzel: String     let einwohnerzahl: String     let nicetoknow: String     let image: Int Das Array: import Foundation // Bitte Ab sofott hier neue Länder einfügen! class CountryItemHolder: ObservableObject{          public let countryList: [CountryItem] = [                  CountryItem(             country_flag: "🇪🇬",             name: "Ägypten",             description: "Ägypten ist ein Land, das Nordostafrika mit dem Nahen Osten verbindet und bis in die Zeit der Pharaonen zurückreicht. Zu den jahrtausendealten Baudenkmälern im fruchtbaren Niltal zählen die kolossalen Pyramiden und die Große Sphinx von Gizeh sowie die hieroglyphenbedeckten Wände des Karnak-Tempels und die Gräber im Tal der Könige bei Luxor.",             hauptstadt: "Kairo",             währung: "Ägyptisches Pfund",             währungskürzel: "egp",             einwohnerzahl: "102,3 Millionen",             nicetoknow:"In den meisten touristischen Orten werden Kreditkarten als Zahlungsmittel akzeptiert. Zudem gibt es mehrere Bankautomaten. Das Telefonnetz ist gut ausgebaut. Das Äygptische Stromnetz läuft mit 220V und es wird üblicherweiße der Eurostecker verwendet.",             image: [0,1,2,3]),         CountryItem(             country_flag: "🇦🇹",           name: "Österreich",           description: "Österreich ist ein mitteleuropäischer Binnenstaat. Mehr als 62 Prozent seiner Staatsfläche werden von alpinem Hochgebirge gebildet. Der österreichische Staat wird deshalb auch als Alpenrepublik bezeichnet.",             hauptstadt: "Wien",             währung: "Euro",             währungskürzel: "eur",             einwohnerzahl: "8,917 Millionen",             nicetoknow:"Österreich ist ein EU-Mitgliedsstaat. Österreich verlangt Mautgebühren für ihre Autobahnen.",             image:[4,5,6,7]),         CountryItem(             country_flag: "🇦🇺",             name: "Australien",             description: "Australien ist ein Land und Kontinent zwischen dem Indischen und dem Pazifischen Ozean. Seine größten Städte – Sydney, Brisbane, Melbourne, Perth, Adelaide – liegen an den Küsten, aber die Hauptstadt Canberra befindet sich im Landesinneren. Bekannte Wahrzeichen des Landes sind die Oper von Sydney, das Great Barrier Reef, das Outback genannte, wüstenartige Inland sowie einzigartige Tierarten wie Kängurus und Schnabeltiere.",             hauptstadt: "Canberra",             währung: "Australischer Dollar",             währungskürzel: "aud",             einwohnerzahl: "25,69 Millionen",             nicetoknow:"",             image:[4,5,6,7]),         CountryItem(               country_flag: "🇩🇪",               name: "Deutschland",               description: "Deutschland ist ein Bundesstaat in Mitteleuropa. Er hat 16 Bundesländer.Die bevölkerungsreichste deutsche Stadt ist Berlin; weitere Metropolen mit mehr als einer Million Einwohnern sind Hamburg, München und Köln; der größte Ballungsraum ist das Ruhrgebiet. Frankfurt am Main ist als europäisches Finanzzentrum von globaler Bedeutung.",               hauptstadt: "Berlin",               währung: "Euro",               währungskürzel: "eur",               einwohnerzahl: "83,24 Millionen",               nicetoknow:"",               image:[4,5,6,7]),         CountryItem(             country_flag: "🏴󠁧󠁢󠁥󠁮󠁧󠁿",           name: "England",           description: "England ist Teil der Britischen Inseln und grenzt an Schottland und Wales. Die Landeshauptstadt London liegt an der Themse. Sie ist Sitz des Parlaments und beherbergt Big Ben und den Tower of London aus dem 11. Jh. Die Metropole ist auch ein wichtiges Kunst- und Geschäftszentrum. Weitere Großstädte sind Manchester, Birmingham, Liverpool, und die Universitätszentren Oxford und Cambridge.",             hauptstadt: "London",             währung: "Britische Pfund",             währungskürzel: "gbp",             einwohnerzahl: "55,98 Millionen",             nicetoknow:"",             image:[4,5,6,7]),         CountryItem(             country_flag: "🇫🇷",             name: "Frankreich",             description: "Frankreich im Westen Europas ist ein Land mit mittelalterlichen Städten, Bergdörfern und Mittelmeerstränden. Die Hauptstadt Paris gilt als erstrangiges Mode- und Kulturzentrum. Hier befinden sich Wahrzeichen wie der Eiffelturm. Uralte Malereien in der Höhle von Lascaux sind Zeugnisse der reichen französischen Geschichte, ebenso wie das römische Theater in Lyon oder das prunkvolle Schloss Versailles",             hauptstadt: "Paris",             währung: "Euro",             währungskürzel: "eur",             einwohnerzahl: "67,39 Millionen",             nicetoknow:"",             image:[4,5,6,7]),                           ] } For "image: [0,1,2,3])," this error message occurs. I have named the images like this. error message: Cannot convert value of type '[Int]' to expected argument type 'Int'
1
0
1k
Sep ’22
I cannot store and retrieve values, texts or data // Planner App
Hi. I want to make a planner app that has the date and location of the project. Only I have a problem. I used a "DatePicker" so that the date is counted. Only I do not know how to save and display the selected date. In general I have problems to save and reload the content of the variables and texfielders etc. I thought that these contents are automatically saved on the end device of the user. I have read that there are methods like "UserDefaults", "CoreData" or "AppStorage". Have been reading stuff about this forever. But I can't get this to work. I hope someone would like to donate their time to help. Greetings Janik
6
0
1.3k
Jun ’22