Post

Replies

Boosts

Views

Activity

Inform users that they need to delete and reinstall the app
Hi, My app has been on the store for a few months now with a few updates. Now I plan a major update that will affect the structure of core data itself (key attribute replaced by relationship). I see no other way than asking the users to delete and reinstall the app to reset all data and start it as new. In a previous update I provided users the possibility to backup their data in a file so they can restore it with the future release. Is there a better way than using the "What's new in this version" section to pass the message to the users ?
3
0
223
4w
Get rid of the task time displayed by the system
When I run my app in debug mode, whenever a time consuming task is run (like a core data fetch request) there is a time indication appearing on top of the view. I am unable to find the meaning of this and how it is named. It looks like: "appName NNNN ms" (it is not caught by the screen shot) Can someone tell if it is possible to get rid of it and how ? Thanks for your help !
1
0
720
May ’24
Changing background color of a textview
I have a View with a few TextViews, which look almost fine except the background color of the textviews that is white, where I would like it to be blue: Here the code: VStack { HStack { TextField("mot", text:$tfMot) .dynamicTypeSize(.xLarge) .disabled(true) .background(Color("fondbleu")) TextField("orthoAlt", text:$tfOrthoAlt, axis: .vertical) .dynamicTypeSize(.small) .background(Color("fondbleu")) .disabled(true) } TextField("Définition", text:$tfDefinition, axis: .vertical) .background(Color("fondbleu")) .disabled(true) TextField("Anagrammes", text:$tfAna, axis: .vertical) .background(Color("fondbleu")) .disabled(true) TextField("Extensions +1", text: $tfExt, axis: .vertical) .background(Color("fondbleu")) .disabled(true) } As one can see, the modifier: .background(Color("fondbleu")) has no effect. I found out that the background color would change only if I ad the modifier: .textFieldStyle(.plain) But then, apparently all the attributes of the default text field style are lost and the text is stuck in the upper right corner of the field: My problem now is how to get the text back in the vertical center of the field. By the way, I tried to fix it using the attributes inspector panel but this one is frozen: Any one can help me out ?
1
0
592
Mar ’24
How to retrieve all records that have a common parent relation
I have set a core data structure based on two entities : first entity is "Mot" (Word) with one String attribute "graphie" (spelling) and one ToOne relationship "definition" with the second entity. second entity is "Definition" that has one String attribute "enonce" (statement) and on ToMany relationship "mot" with entity Mot. One word can have several spellings but only one definition. I managed to load several rows of data and now, when I select one word I want to display all the spellings, which means all "Mot" that have the same definition. In my content view I have a List based on a request: @Environment(\.managedObjectContext) private var viewContext @FetchRequest(entity: Mot.entity(), sortDescriptors: [NSSortDescriptor(key: "graphie", ascending: true)]) private var mots: FetchedResults<Mot> var body: some View { NavigationView { ... List { ForEach(mots) { (mot: Mot) in HStack { Text(mot.graphie ?? "Non trouvé") Spacer() Text(mot.definition!.enonce ?? "Non trouvé") } .onTapGesture { motAffiche = mot tfMot = mot.graphie ?? "Not found" tfDefinition = mot.definition?.enonce ?? "Not found" tfOrthoAlt = returnOrthoAlt(mot: mot) } } } the function returnOrthoAlt(mot) is supposed to return a string with all spellings separated by commas. What is working for the moment, but not satisfactory is the following code for that function private func returnOrthoAlt(mot: Mot) -> String { var ort = [String]() for elem in mots { if elem.definition!.enonce! == mot.definition!.enonce! && elem != mot { ort.append(elem.graphie!) let defObjId = elem.definition!.objectID.uriRepresentation() print("\(elem.graphie!) def: \(elem.definition!.enonce!) \(defObjId) ") } } return if !ort.isEmpty { ort.joined(separator: ", ")} else {""} }: I am going through the table 'mots' of FetchedResults to find those that have the same definition as the current 'mot'. What I find not satisfactory is that I am comparing the 'mot.definition.enonce' of each Mot, which is not supposed to be unique, instead of 'mot.definition' directly, which did not work. The objects 'mot.definition' are obviously not equal (neither with == nor with === operators). Also I tried to retrieve the reverse relation directly with 'mot.definition.mot' but that returned a NSSet which, converted to a set seems to contain only one object, that is 'mot' itself. One possibility of course, would be to ad a unique Id to the entity 'Definition' but I seem to understand that this is not the recommended practice, the more so as swift does not provide system generated id. What do I miss in the core data concept ? Can someone help me out ?
1
0
483
Mar ’24