Posts

Post not yet marked as solved
1 Replies
92 Views
I used List(select:) to make it selectable. When scrolling to select many rows, the selected content sometimes disappears. Is running out of memory a problem? While the default app in ios has smooth multi-selection, it is unstable when using swiftui's list function. Multi-select in the mail app, for example, doesn't run out of memory when many rows are selected. How do you achieve this perfection? The code is nothing special. Create a list with List(select:) and rows with ForEach(array, id:.self). I'll attach a video https://i.stack.imgur.com/2px9i.gif
Posted
by nubkordev.
Last updated
.
Post not yet marked as solved
0 Replies
145 Views
Is there a way to optimize a List in SwiftUI? There is a problem with selection not working properly when the List has many rows. If you scroll to multi-select and up, some rows in the middle are not selected. I have an issue where selecting an unselected row deselects nearby rows. Is there any way for selection to work reliably even for a List of many rows? I would like to find a solution that is stable even when multiple lines are selected, like mail and note, which are the default apps in ios. ps. I am using CoreData. @State var selectedItem = Set<MyEntity>() List(selection: $selectItem){   ForEach(items, id: \.self){ item in     ContactsRow(contactsData: item)   } } .environment(\.editMode, $editMode)
Posted
by nubkordev.
Last updated
.
Post not yet marked as solved
0 Replies
142 Views
overview of the problem I'm making an app with SwiftUI. We even implemented fetching contacts using CNContactStore. The goal is to get the contacts and store them separately in CoreData. This is because you need to assign and manage attributes that are not in the default contact. class ContactStore: ObservableObject {   @Environment(\.managedObjectContext) private var viewContext   @Published var error: Error? = nil   @Published var results: [CNContact] = []       func fetch() {     do {       let store = CNContactStore()       let keysToFetch = [CNContactGivenNameKey as CNKeyDescriptor,                 CNContactMiddleNameKey as CNKeyDescriptor,                 CNContactFamilyNameKey as CNKeyDescriptor,                 CNContactImageDataAvailableKey as CNKeyDescriptor,                 CNContactPhoneNumbersKey as CNKeyDescriptor,                 CNContactImageDataKey as CNKeyDescriptor]       os_log("Fetching contacts: now")       let containerId = store.defaultContainerIdentifier()       let predicate = CNContact.predicateForContactsInContainer(withIdentifier: containerId)       let contacts = try store.unifiedContacts(matching: predicate, keysToFetch: keysToFetch)       os_log("Fetching contacts: succesfull with count = %d", contacts.count)       self.results = contacts       print(results)     } catch let error {       print("error occured! : \(error.localizedDescription)")     }   } } problem Is there a way to store the contact information in the array 'results' as CoreData? The attributes set in CoreData are 'name', 'phone', and 'company'.
Posted
by nubkordev.
Last updated
.
Post not yet marked as solved
0 Replies
196 Views
I am using coredata. Draw a rectangle by taking only 2 values ​​with ForEach. However, when I add new data or modify the data, the app crashes. ForEach must have a maximum index value of 1. This is because the limit of fetchrequest is 2. However, when I add new data, the value of index becomes 2 and get an 'out of range' error. I've been looking for an answer for 16 hours. import SwiftUI struct chart: View{   @Environment(\.managedObjectContext) private var viewContext   @FetchRequest var datas: FetchedResults<Mind>       @State var show = [true, false]       init() {     let request: NSFetchRequest<Success> = Mind.fetchRequest()           request.sortDescriptors = [       NSSortDescriptor(keyPath: \Success.date, ascending: false)     ]     request.fetchLimit = 2     _datas = FetchRequest(fetchRequest: request)   }       var body: some View{     VStack(alignment: .leading){       ForEach(0..<datas.map{$0.suc}.count, id: \.self){ index in         RoundedRectangle(cornerRadius: 5)           .fill(Color.objcolor.opacity(show[index] ? 1 : 0.7))           .frame(width: 10, height: 5)       }     }   } }
Posted
by nubkordev.
Last updated
.
Post not yet marked as solved
0 Replies
208 Views
Open the detail view with navigationlink. How to edit data in detail view? Is there a way to automatically save when I edit text in textfield like note app? I use coredata.
Posted
by nubkordev.
Last updated
.
Post not yet marked as solved
0 Replies
248 Views
I want to plot the data stored in coredata as a chart. (using SwiftUI) The entity structure of the project is as follows. entity name: Item attribute : name(String), success(Int), date(Date) Among the above attributes, I want to draw the trend of the success attribute as a bar chart. I did find a suitable package for drawing charts. It is 'Charts' by appear. To draw a chart, you need to put success data in the data array, which is difficult. Either way it doesn't matter. Please suggest a specific way to draw a chart. For reference, I am attaching the code I used. import SwiftUI import SwiftUICharts import CoreData struct ChartView: View{     @Environment(\.managedObjectContext) private var viewContext     @FetchRequest var items: FetchedResults<Item>          var demoData: [Double] = []     @State var thinkData = []          init() {         let request: NSFetchRequest<Item> = Item.fetchRequest()                  request.sortDescriptors = [                 NSSortDescriptor(keyPath: \Item.date, ascending: true)             ]                           request.fetchLimit = 7         _items = FetchRequest(fetchRequest: request)                  for i in items{             demoData.append(Double(i.success))         }     }               var body: some View{         HStack{             Spacer()             BarChart()                 .data(aData)                 .chartStyle(ChartStyle(backgroundColor: .white,                                                foregroundColor: ColorGradient(.blue, .purple)))             Spacer()         }     } }
Posted
by nubkordev.
Last updated
.
Post not yet marked as solved
0 Replies
274 Views
I want to get data from coredata and present it as a chart. During the build process, it builds without any problem, but the chart is not visible when the actual app is run. I put some data in coredata. Why? import SwiftUI import SwiftUICharts import CoreData struct ChartView: View{     @Environment(\.managedObjectContext) private var viewContext     @FetchRequest var items: FetchedResults<Item>          @State var demoData: [Double] = []          init() {         let request: NSFetchRequest<Item> = Item.fetchRequest()                  request.sortDescriptors = [                 NSSortDescriptor(keyPath: \Item.timestamp, ascending: true)             ]                           request.fetchLimit = 7         _items = FetchRequest(fetchRequest: request)                  for i in items{             demoData.append(i.think)         }     }          var body: some View{         BarChart()             .data(demoData)             .chartStyle(ChartStyle(backgroundColor: .white,                                            foregroundColor: ColorGradient(.blue, .purple)))     } }
Posted
by nubkordev.
Last updated
.
Post not yet marked as solved
1 Replies
227 Views
I am studying using core data. Especially the fetchrequest is difficult. Can't i save the last 7 values ​​of a specific attribute of coredata in an array? The goal is to use the charts package. I want to call 7 attribute values ​​and express them in a chart.
Posted
by nubkordev.
Last updated
.
Post not yet marked as solved
2 Replies
268 Views
I want to store the last 7 data of Core Data in an array. The structure of the entity is as follows. date, title, goal, nogoal, id. I want to store the last 7 goal records in an array. If there is an angel who can do it, please help me.
Posted
by nubkordev.
Last updated
.
Post not yet marked as solved
0 Replies
186 Views
Can't i just store specific attributes of an entity as an array? Entity : goals attributes : date(date), title(String), goal(Int16), failgoal(Int16), id(UUID)
Posted
by nubkordev.
Last updated
.
Post not yet marked as solved
0 Replies
167 Views
I want to save the data in Core Data as an array and express it as a chart. Can data in Core Data be combined by date and expressed in a chart?
Posted
by nubkordev.
Last updated
.
Post marked as solved
9 Replies
1.6k Views
I'm making an Apple Watch app and an iPhone app. The structure of the app is as follows. (On Apple Watch) Count the number and store it in Userdefault.(title, number) (On Apple Watch) Press the 'Count Complete' button to send the title and number data to the iPhone app. (In the iPhone app) Save the data received from the Apple Watch as CoreData. Here's the problem. I don't know the proper way to transfer the data (title, number) generated by the Apple Watch to the iPhone.
Posted
by nubkordev.
Last updated
.
Post not yet marked as solved
0 Replies
262 Views
I have a problem with CoreData. Is there any way to directly save the data received by WCSession didreceiveuserinfo to CoreData?
Posted
by nubkordev.
Last updated
.