core-data

How to use the generated classes after Xcode did “Class Definition” for Core Data?

可紊 提交于 2020-02-06 07:56:10
问题 I'm using Xcode 11.3.1 and I choose Class Definition for example Entity in a new project. I can't seem to reference the generated class. Even after I press build let x = Project() Use of unresolved identifier 'Project' 回答1: Can't reproduce. I created a new vanilla Single View app with Core Data direct from the template and made one Entity just like yours: Then I added one line of code to the view controller's viewDidLoad ; it compiles just fine: class ViewController: UIViewController {

use uitextfield delegetate to fetch coredata binary data by its count number

一曲冷凌霜 提交于 2020-02-06 07:41:25
问题 My swift code saves 3 names to core data entity "username". I want to use uitextfield delegate to pull a specific string. So when the user enters 2 in the textfield. On the label labelName the name jessica Biel should appear. So the user enters a number into a textfield a string appears on the label. If number 1 is enter the 1st NSManagedObject into the core data entity userName. Link to project https://github.com/redrock34/jessicaBiel import UIKit import CoreData class ViewController:

Coredata after Application Update

那年仲夏 提交于 2020-02-05 05:52:30
问题 I'm trying to implement a process for my application that makes the posibility to update the app when needed, and with update I mean donwnload the newer application .ipa in the device. The thing is that I'm using CoreData to store the server data brought at the first launch, and between the old version and the newer one I've added some entities and atributes for some old entities to the DB. That makes conflicts, as I have no idea how to handle migrations and/or any thing that can provide me

API calls blocks UI thread Swift

一个人想着一个人 提交于 2020-02-05 04:20:07
问题 I need to sync web database in my coredata, for which I perform service api calls. I am using Alamofire with Swift 3 . There are 23 api calls, giving nearly 24k rows in different coredata entities. My problem: These api calls blocks UI for a minute, which is a long time for a user to wait. I tried using DispatchQueue and performing the task in background thread, though nothing worked. This is how I tried : let dataQueue = DispatchQueue.init(label: "com.app.dataSyncQueue") dataQueue.async {

How to have a A-Z index with a NSFetchedResultsController

守給你的承諾、 提交于 2020-02-04 12:52:33
问题 I'm using a NSFetchedResultsController for my table view and I would like to have an index A-Z. The problem is that if I use the entity's attribute for which I want to have section, it will return as many section as there are different names for this attribute. So I was thinking to add another attribute in my NSManagedObject subclass. This attribute would be only the first letter of the other one. So I found out this topic where they explain how to do it but: it's an pretty old one so I was

How to have a A-Z index with a NSFetchedResultsController

最后都变了- 提交于 2020-02-04 12:51:35
问题 I'm using a NSFetchedResultsController for my table view and I would like to have an index A-Z. The problem is that if I use the entity's attribute for which I want to have section, it will return as many section as there are different names for this attribute. So I was thinking to add another attribute in my NSManagedObject subclass. This attribute would be only the first letter of the other one. So I found out this topic where they explain how to do it but: it's an pretty old one so I was

SwiftUI Preview doesn't work with FetchRequest and Init

↘锁芯ラ 提交于 2020-02-04 05:29:05
问题 I have a problem with SwiftUI Preview not working sometimes (but not giving me any errors, just a blank Canvas). I have narrowed down the problem - it doesn't work when I'm using fetchRequest with init. But I don't know what to do next. Preview works with this code: import SwiftUI struct ListView: View { var fetchRequest = FetchRequest<NPBooking>(entity: NPBooking.entity(), sortDescriptors: []) var bookings: FetchedResults<NPBooking> { fetchRequest.wrappedValue } var body: some View { ForEach

Many to many relationship core data query for specific collection

让人想犯罪 __ 提交于 2020-02-04 05:26:26
问题 public enum Ability: String { case newcomer = "Newcomer" case beginner = "Beginner" case intermediate = "Intermediate" case advanced = "Advanced" } public enum Group: String { case solo = "Solo" case duo = "Duo" case team = "Team" } I want to find all performances that match the following. ability == "Beginner" group == "Duo" performers == "Jane Davies" && "Alice Evans" The documentation suggests that aggregate operations in core data are not supported, which is surprising. Questions like

How to store JSON decodable values into Coredata using Swift

放肆的年华 提交于 2020-02-04 01:18:32
问题 I am trying to load JSON Data into CoreData . Here, I used JSON structure for decodable and after that I am trying to fetch the decodable Data into CoreData. I don’t know how to use decodable with iterate the data and fetching into coredata. Below code I tried, but not getting proper result. Please help me to resolve this. My JSON { "status": true, "data": [ { "id": "20", "name": "ar1" }, { "id": "21", "name": "ar2" }, { "id": "22", "name": "ar3" } ] } My Structure For JSON struct userList:

Core Data lightweight migration crashes after App update

一世执手 提交于 2020-02-03 11:40:11
问题 Two days ago I released the App. According to feedback on AppStore and crash reports from itunesconnect there are a lot of crashes on launch. But not 100% users suffered, only 30% maybe. I've read the crash logs and saw a problem. It's crashing on DB migration process. I use lightweight migration of database. Usually I add new datamodel version very carefully. Even before each release I install a previous version of the App, use it for some time and only then I install the latest version