Questions tagged [core-data]

Core Data is Apple's object modeling and persistence framework for macOS and iOS. Xcode provides an object model editor for specifying entities, attributes, and relationships.

0
votes
0answers
23 views

Parse 100 elements only at first launch of app iOS

I have to get 100 elements via HTTP GET request with some APIs, but only at the first launch of the app. What should I do? Here is what I tried to do, but it's not working. I put this code in the ...
0
votes
1answer
29 views

How to allow user to turn on ONLY a single uiSwitch that is built programmatically and store data of the switch

I have a programmatically built uiswitch in my car register tableview that when the user switches it on for the car of their choice, the boolean is saved and stored in core data and the car brand will ...
0
votes
1answer
24 views

How to store the core data files in the Private folder

I have released the iOS app to the user through Adhoc distribution. The user has installed the app and they are able to view the files such as sqlite files, images stored in the documents directory. ...
0
votes
0answers
31 views

Backup and restore core data model FILE in CloudKit

It seems it's not easy to sync CoreData entries with Cloudkit. So I wonder if it is possible to backup the entire .xcdatamodeld file in the user iCloud storage and then the user can restore the file ...
-2
votes
0answers
17 views

CoreLocation storage in order to query by proximity

I need to store the users location in core data. I understand that the best way to do this is to store the latitude and longitude as doubles.This doesn't seem very good for my porpoise. My question is:...
-1
votes
4answers
25 views

iOS - Will application get crash after writing UI updation code on background thread

If I write accidentally UI updating code on a background thread after fetching data from network req. So Will my application get crash?
-1
votes
0answers
46 views

CoreData predicate filter by relationship attribute

I have the following class structure in my Swift iOS app using CoreData: class PersonWrappper { person: Person someOtherAttribute: Int } class Person { name: String age: Int } I ...
0
votes
0answers
18 views

iOS: This NSPersistentStoreCoordinator has no persistent stores => How to check if the sqlite database in the app correspond to the model?

I would like to check if an old sqlite is present in the app and doesn't match to the new model. For example if I added some tables in the coredata model, I would like to avoid a crash if the app ...
0
votes
2answers
28 views

UIImagePickerController - how to save image to core data? (Swift)

I want to save the image that I have picked from the ImagePicker and I want to save it in my CoreData. I create Attribute in my Entity with Binary Data type.
0
votes
0answers
55 views

How to save data in a UITableview with core data- Swift code

I'm wondering if someone can show me how to save the data in tableview with core data? I have an app that is required to store a lot of user input in table view. I have been using UserDefault which I ...
1
vote
1answer
42 views

SaveContext multiple times inside performBlock

I have flow where I should create object save it in CoreData. But by the flow I need to update object every X seconds and update it with saving context. And because there is possibility of terminating ...
0
votes
1answer
24 views

How can i do core data migration?

I have an old core data version with Allows external storage in Binary data. And i have created a new one where Allows external storage was unchecked. When i tried to launch my app i got an error: ...
-1
votes
0answers
18 views

Fetching as String from CoreData to a label [closed]

I am new to swift and would need some guidance. I would like to display a random name fetched from CoreData to a label. A button should return a random name chosen from the several names I already ...
0
votes
1answer
17 views

Storing a (long long) in a CoreData model

Very beginner-level question here that I can't seem to solve: In Objective-C, I can get millis since 1970 with (long long)([[NSDate date] timeIntervalSince1970] * 1000.0) (from here). I'd like to ...
0
votes
1answer
40 views

Core data + localization

I have a simple Core Data Entity "Task to perform" that contains Attribute of type String. Core Data model is prepopulate from file under first app launch, and "Task to perform" attributes contains ...
-3
votes
1answer
38 views

Login SignUp verification with the CoreData in Swift

I want to setup the login verification with the saved CoreData in Swift. In other word if the UserName and Password is correct then user can login otherwise it shows error(Incorrect password Or ...
0
votes
0answers
29 views

Swift - Save new position of button/image after being dragged using Core Data

I am creating a new button programmatically which I can drag to the desired position in the view. I want to save the new coordinates to my Core Data but the values are returning 0 for the clip....
-2
votes
0answers
27 views

NSSortDescriptor sorting by number in string property? [duplicate]

I have a string core data property trackString in my Track core data model which i'd like to use as a way to sort by the track number. There are 11 Track objects which have the track strings Track 1, ...
1
vote
1answer
51 views

Swift / iOS Core Data - Save Large Amount of Records in Background Thread

I am working on an iOS app (Swift) which fetches a huge amount of data (21000 records) through a web service (in chunks of 1000 records per request). And at the end of each request I need to store ...
0
votes
2answers
33 views

Where is the location of the sqlite file in IOS 12?

I am unable to locate the sqlite file for the IOS simulator. I need the file in order to inspect the data in the database for debugging. Previously I would use: NSLog(@"Documents Directory: %@", [[[...
-1
votes
0answers
16 views

How to retrieve deleted Core Data attributes?

I have a core data entity called "Expense" which has the following attributes: However, I accidentally deleted 2 of the attributes from the list: "collection" and "category". When I have added the ...
2
votes
1answer
32 views

Fill CoreData with a large SQL database

I have a large 180k row SQL (mysql) database that I want to use in CoreData. Can I create the SQLite database using Xcode, then use an SQLight client app to connect to that database, and fill it using ...
-1
votes
1answer
25 views

Undefined symbol trying to link XCTest target

I am trying to test my application that uses Core Data. In order to test the my "save" method, I am using XCTNSNotificationExpectation for the notification NSManagedObjectContextDidSave, as shown ...
0
votes
0answers
55 views

How 20K objects can be efficiently saved into CoreData in Swift?

I wondered if there is an efficient way to save 20.000 objects into CoreData. Currently saving them takes about 2 minutes and it would be great if I could make it faster. Now I'm doing the saving in ...
1
vote
1answer
42 views

How do I store array of custom objects in core data?

Core data is still a bit new for me, so I don't quite understand the ins and outs. I understand how to save the basics like Strings, Ints, etc in core data, but I don't quite understand how to save an ...
0
votes
0answers
23 views

Fetching images and videos in UICollectionView swift

I've used PHAsset principle to fetch images and videos, but only images are shown. I've also tried to change it to NSPredicate, it crashed. So, please, can anyone help me with this issue? private ...
3
votes
1answer
56 views

Swift: Sorting Core Data child entities on fetch based on Date

Introduction I'm making a calendar app in which I store events using Core Data. Its composed of: DateKey as the parent (with a one-to-many relationship) to CalendarEventModel. The concept is that ...
0
votes
1answer
11 views

How to prevent Xcode from making inconsequential changes to data model file

I'm working with Xcode Version 10.0 (10A255) on MacOS High Sierra 10.13.6. I have the data model file (myproject.xcdatamodel/contents) in Git and that's great for tracking changes. The problem I have ...
0
votes
0answers
22 views

Core Data Implementation for Photo Recognition App

I am in the process of creating photo recognition app that uses core data to persist the users' images that have been loaded into the app either from the photo library or the camera. I have been ...
0
votes
2answers
27 views

Class function returning Self? for Core Data abstract class

I have a Core Data class List inheriting from abstract type Synchronizable. The later is parent to several other classes that I intend to sync with my server. I would like to factor a class function ...
0
votes
0answers
30 views

CoreData crash after returning from background

In my app, I have this one CoreData context that I approach in all my view controllers as follows: let managedObjectContext = (UIApplication.shared.delegate as! AppDelegate).persistentContainer....
2
votes
1answer
33 views

How to combine 2 CoreData predicates in Swift?

I have a function: open func getAllCarsCount(from garages: [Garage], with categories: Set<Category> = []) -> Int { var returnCount = 0 let context = DBContext.defaultContext var ...
0
votes
3answers
45 views

toggle button with boolean in UITableView Swift

I would like to add a boolean toggle to know whether the button has been pressed (will save this value to core data (also would like to save cell data to core data if true and delete from core data if ...
-2
votes
0answers
31 views

How to write to CoreData from Today extension

I am trying to write to Coredata from Today extension in iOS app using App Groups. This link https://www.innoq.com/en/blog/ios-writing-core-data-in-today-extension/ provides some answer, but it doesn'...
1
vote
0answers
35 views

Adding new entity to existing data model causes the users data to disappear (lightweight Core Data migration doesn't work)

I've got my app in the App Store with datamodel in version 2. I created version 3 of the data model, set it as current and add 1 new entity to it (attributes are marked as Optional). This new entity ...
1
vote
1answer
27 views

Swift CoreData using predicates with Array

I need to keep array of Strings in CoreData and later on use predicates for filtering data for that array. According to this post field type Transformable (with custom class [String]) does the trick ...
0
votes
2answers
24 views

App crashing when fetching NSObjects from background

I have a notification with NotificationCenter.default that triggers a prune method which crashes when trying to fetch from my store. This is the method: @objc fileprivate func pruneBooks() { ...
0
votes
1answer
17 views

Swift - How to Properly Implement Updating/Setting Up of CoreData for use prior to ViewController loading

My situation is as follows: I will be using CoreData to store/fetch entity instances to be displayed in a tableView. At the start of the app, I have the app check the version of the current library, ...
0
votes
0answers
29 views

ClassName+CoreDataClass.swift not generated in Xcode10

I updated my Xcode from 9.4.1 to 10 (stable release) and I'm trying to update my Core Data model. I set the Codegen to Manual/None as before, but when I do Editor -> Create NSManagedObject subclass ...
1
vote
1answer
44 views

KVO not working for custom property of NSManagedObject

I have a subclass of NSManagedObject Folder with a state of Availability @objc enum Availability: Int16 { case unknown case available case unavailable } Folder has to do extra stuff (like ...
1
vote
0answers
20 views

Core Data fetch using predicate with date calculation sometimes crashing

I have a ResponseCacheRecord entity in my Core Data model with these attributes (amongst a few others): removeWhenExpired (non-optional Boolean) timestamp (non-optional Date) validDuration (non-...
1
vote
1answer
50 views

Dynamic filtering with Swift CoreData

I am developing an application that retrieves data from CoreData. I retrieve a list of items from the database and display these on screen. The user has an option to filter these items for up to 5 ...
1
vote
1answer
62 views

Core Data: Binary Data attribute becomes nil when other attribute is changed

My app has a Core Data entity (called Product) that has two attributes: A name of type String An image of type Binary Data (with "Allows External Storage" checked) Right now since I am developing, I ...
2
votes
0answers
51 views

IOS 10+ Persistence Store Container set parent context to main context

Following a perfect core data stack, we follow this hierarchy. For IOS 10+, Apple introduced NSPersistentContainer. In which Apple described the way for getting background context by let ...
24
votes
1answer
2k views

iOS 12 specific problem: Core Data External Storage Binary Data corruption

I've spent the better part of a workday trying to solve this. Background I have a simple core data model, with books and reading sessions. The books have covers (images) that are stored as binary ...
0
votes
0answers
40 views

How to save and edited tableView cell row data to coredata and device contact?

I create contact viewController like this: which when user click add phone, it will insert new blank phone row in tableView cell, which can be edited on phone number textfield and phone type name ...
0
votes
1answer
35 views

How to start a project using CoreData in Xcode 10?

Starting a project in Xcode 10 doesn't present the checkbox found in previous versions of Xcode. How do I include CoreData in my project?
0
votes
1answer
29 views

Delete record in Core Data with CollectionView

I would like delete a record in the Core Data when you tap on a close button in your CollectionView Cell. I made a UIButton in the Collection View Cell controller with an extension in the ...
0
votes
1answer
15 views

on to many inverse process [duplicate]

I stored data in core data as one-to-many relationship, where one is the parent and many are children How can I know if I have the child which parent is related to it? I know how to fetch children ...
0
votes
1answer
114 views

Build input file cannot be found for generated Coredata class and extension when open project on different computer

I am new to Core Data and my first project I build using it work perfectly on my main computer. However, when I push the code to git repo, my other team mate encounter problem. More specifically the ...