Questions tagged [core-data]

10440 questions
1

votes
1

answer
100

Views

Find nearest number in Core Data without iterating over data

I know it's currently not possible to find the nearest geo-location in Core Data without loading all data and doing it manually in code, but is it at least doable with simple numbers? Can I, for example, have a table with entries, with the values 1, 2.5, 4, I search for 3.6 and get back the entry wi...
Jan
1

votes
2

answer
1.7k

Views

Set value for key in case of NSInteger

I am trying to set a value in core data using setValue:forKey: but it is throwing an error: (Use of undeclared identifier: 'newID'} when trying to save an NSInteger. Can anyone suggest the correct syntax? NSInteger newID = lastID+1; [record setValue:newID forKey:@'localid'];//error Got similar erro...
user1904273
1

votes
1

answer
362

Views

Bug with FetchedResultsController after setting it to nil in viewWillDisappear

In my iOS (Swift 3, Xcode 8) Core Data app I have 2 View Controllers (CategoriesViewController and ObjectsViewController) (Both are inside the same navigation controller). Each ViewController has it's own tableView and it's own fetchResultsController to manage the results returned from Core Data req...
Adelmaer
1

votes
1

answer
47

Views

How do I delete elements from core data?

I am implementing a delete button that deletes the terms and definitions from core data. The implementation I have tried hasn't worked. What is wrong with my deletePressed function and how can I make it work correctly? @IBAction func deletePressed(_ sender: Any) { do { fetched = try context.fetch(C...
Noah Iarrobino
1

votes
0

answer
30

Views

Core Data: split into sections based on custom logic

I have a large data set of objects, made up of 2 large-ish subsets. Set 1 has about 10,000 objects in it. Set 2 has about 70,000 objects in it. The object sets have many-to-many relationships between them. There are also 'favorites' subsets for both sets. Before I display set 1 or set 2, I will have...
mbm29414
1

votes
0

answer
247

Views

Swift 4; coredata context.delete is not deleting

I looked for all exaples and checked all the types and objects. All looking fine. But ... the code below doesn't delete the data. No error and all print statements are indicating that the record should be deleted.The deleteDeelnemer is exactly the object I wanted to delete. Print statement succesful...
Marcel
1

votes
0

answer
29

Views

Efficiently pass core data objects to common detailViewController

I have a number of entities that describe different pieces of equipment. I read these into the EquipmentViewController. I'm struggling to figure how to use a generic EquipmentDetailViewController that can be used to show and update any of the different entities. I have it working by having a separat...
David DelMonte
1

votes
0

answer
74

Views

Is it safe to delete old CoreData xcdatamodel versions?

In my project I have too many CoreData model versions (two-digit number). It's a years-long project and stuff has been changed quite a bit through time. If I'm 100% sure all my users are using the latest model for quite some time now, is there a way I can get rid of old models and 'start fresh' with...
mixtly87
1

votes
1

answer
46

Views

Long CoreData predicate to match multiple terms to attribute + relationships

I’m using swift 4, Xcode 9, iOS 11 I am continuing to learn about CoreData via tutorials and Q&A posts, but I can’t seem to figure out how to answer this question. I have a CoreData entity with one attribute and 12 relationships to different entities that each contain 1-3 attributes. This is bec...
Coltuxumab
1

votes
0

answer
204

Views

Xcode 9.2 Coredata issue

I am working on a Swift project where I used Coredata. In Xcode 9.1 project running fine but in Xcode 9.2 I am getting following error: :0: error: no such file or directory: '/Users/aliapple/Library/Developer/Xcode/DerivedData/ClaimIt-gvtrxwzmxtcxxtbbbkwqcuqqzvhk/Build/Intermediates.noindex/ClaimIt....
Mehtab Ahmed
1

votes
1

answer
92

Views

What is considered too heavy for UserDefaults?

I'm building a simple iOS app that will be the first I'll have put on Apple's App Store. At one point, the app accesses the user's contact list and lets them select any number of contacts they want to save as favorites. For ease of building version one, I am currently using UserDefaults to save thes...
rtoken
1

votes
0

answer
758

Views

CoreData Sync with CloudKit or iCloud

I'm using Swift 4 and I have 3 to 4 CoreData entities in my project. I want to sync CoreData with iCloud for sharing on other devices and also for a backup of data. I have seen more questions on StackOverflow related this but not found any solution in Swift 3 or Swift 4. I think CoreData to iCloudKi...
Jon Striker
1

votes
1

answer
39

Views

Universal context for CoreData

I use NSPersistentContainer as a dependency in my classes. I find this approach quite useful, but there is a dilemma: I don't know in which thread my methods will be called. I found a very simple solution for this extension NSPersistentContainer { func getContext() -> NSManagedObjectContext { if Thr...
kasyanov-ms
1

votes
0

answer
24

Views

Objective C: Exported Sqlite to Email has incomplete Data

I am trying to export the sqlite that I've created for core data to store the records locally to the app that I am developing. I have managed to export the sqlite file via e-mail as attachment, but when I extracted the sqlite file the data is not complete, newly added records aren't shown. Here's my...
Risra
1

votes
0

answer
41

Views

What data does Z_SUPER store in iOS Core Data's Z_PRIMARYKEY sqlite table?

I had been fighting sqlite in Simulator importing some test data. I finally set up what I wanted, learned about handling Z_PRIMARYKEY.Z_MAX in the process, but I never figured out what data Z_PRIMARYKEY.Z_SUPER is storing (parent/child entity maybe?). I haven't seen anything on SO regarding this but...
torple
1

votes
1

answer
575

Views

How to move from CoreData to Firebase

So currently, I am making an app in which it allows the user to create expenses and store them. Each expense has properties such as date, name, amount, type of expense, category and etc. Currently, I am storing all of this on CoreData, which I find is easy and manageable, however I really want to mo...
Arnav GUPTA
1

votes
2

answer
332

Views

How to use NSFetchedResultsController to update tableview content

I am updating certain parts of coredata and I want the NSFetchedResultsController to automatically reload the tableview with all the animations. I am changing a coredata element that is used to sort tableview. I am doing this by swiping to the right on the cell and then changing that particular tabl...
Osama Naeem
1

votes
1

answer
76

Views

Core Data swift3 same primaryKey but different objectId in picker

I'm an absolute newbie with Swift and Core Data. I created a two Entity learning app, nothing special. I'm stuck in finding why (AFAICT) my 'Persona' picker objects in my 'Medicina' Entity are different from the ones shown directly in the 'Persona' Core Data table; since adding a predicate to filter...
elysch
1

votes
1

answer
191

Views

Lexical or Preprocessor Issue happens when using Core Data: '.Friend.h' file not found

I am writing functions of iOS Core Data. I have one Entity named 'Friend', its Codegen is Category/Extension. I have written my own Friend subclass as NSManagedObject. I am facing an issue that Lexical or Preprocessor Issue, '.Friend.h' file not found in file Friend_CoreDataProperties.h which is aut...
Kevin Science
1

votes
0

answer
361

Views

NSFetchedResultsController CoreData UICollectionView insert Issue

I am trying to update using a NSFetchedResultsController/NSFetchedResultsControllerDelegate a UICollectionView. UPDATE The UICollectionView has 21 cells and it has 3 cell in each Row. The idea is that I am downloading some image Data,I am saving them on CoreData on BackgroundContext (backgroundCont...
P S
1

votes
0

answer
229

Views

How can I fetch core data objects into an array

I am trying to build an application that helps dyslectic children to automate words and I cannot get the lists in my app to work as desired: users can create lists [LijstMO] that contain a set of words [WoordMO]. I am able to create and fetch lists, and to create words, but I can't create an army of...
Jeroen De Bruin
1

votes
1

answer
149

Views

Swift: Airdrop/Bluetooth sync CoreData (SQLite) between apps [closed]

I have an app that utilizes a CoreData SQLite database, and would like to be able to synchronize these databases across different devices. To accomplish this, I need help with 2 specific steps: Packaging a coredata database into some kind of store/entity (ex: store container) that can be transferred...
riceman89
1

votes
1

answer
343

Views

Save a copy of sqlite file in Core Data

I am trying to make a copy of current Core Data database file. After doing some research, I found that migratePersistentStore(_:to:options:withType:) might be useful in this situation, as the Apple documentation saying, This method is typically used for “Save As” operations. While the document...
tttemplar
1

votes
1

answer
35

Views

coreData only printing last entity (swift4)

I am trying to call all of my entries of coreData .color. The problem is only 1 entry of coreData is being called to the label. I would like all of the entities of coreData to be printed on the label not just the latest one, which the code is currently doing. import UIKit class ViewController: UIVi...
Sam Burns
1

votes
0

answer
78

Views

Apply sortDescriptor to NSFetchRequest after grouping

I am building a Showroom that has 45000+ catalogs each represented as Literature in CoreData. To optimise search - instead of searching over Literature, I've added another entity - LiteratureSearchIndex in CoreData, that has searchvalue (either title word/keyword/tag etc. that represents part of the...
Valentin
1

votes
1

answer
56

Views

Why function changes type?

During my investigation I discovered strange behavior with Swift, but maybe I don’t understand something. I made small object to test: class BugTest:NSObject { func test(content:[Type]) { func inside(object:Head, type:Tail.Type) { print ('Head: \(Head.self), Tail: \(Tail.self)') } if let first = c...
Łukasz
1

votes
0

answer
69

Views

In which form the map of an ios navigation app is stored?

I am trying to draw a map in an ios app (using the points' coordinates from OpenStreetMap) and I have tried loading the data (i.e., cartesian coordinates of the map's points) both from a plist as well as from a simple text file but in both cases the loading is too slow. Does anybody know in which fo...
ckc
1

votes
1

answer
1.2k

Views

What does “ Value of tuple type '(String, JSON)' has no member 'subscript' ” refer to in Xcode?

So for my file I am trying to use Alamofire to make a request in order to get Photos from Flickr using their API. I am using CoreData, Alamofire, and SwiftyJSON The method is as follow: func getImagesFromFlickr(_ selectedPin: Pin, _ page: Int, _ completionHandler: @escaping (_ result: [Photo]?, _ er...
1

votes
0

answer
250

Views

Should I delete underlying persistent store files after calling destroyPersistentStore on a NSPersistentStoreCoordinator?

I'm migrating my iOS app to use NSPersistentContainer. This class by default locates its persistent store files in the Library/Application Support directory; previously my store files were stored in the Documents directory. I've added a little bit of code to move the store files if they were found a...
Andrew Bennet
1

votes
0

answer
57

Views

NSFetchedResultsController isn't always update

I have a 'Google drive' app, every time I enter folder i have NSFetchedResultsController that fetch the entity with 'parentId' parameter. my NSFetchedResultsController wrapper: class KnowledgeFetchedResultsController { private var controllerContex : NSManagedObjectContext? = appDelegate.coreDataCon...
Yair hadad
1

votes
0

answer
46

Views

Can I use Core Data as a replacement for User Defaults?

I've programmed a few apps using swift where I saved properties using user defaults and the code gets a little long as I start to user more variables. I'm now working on an app with a player class that has 6 properties and there are 100 players, so rather than write 600 save and 600 load lines for u...
Dominick
1

votes
1

answer
139

Views

swift codegen file error

Working with coredate I used the option codegen: category/extension to be able to create a file where I can put in the re-usable code for finding, updating or deleting database entries. I started the coredata entity first with the codegen option Class Definition and changed it to category/extension...
Marcel
1

votes
1

answer
46

Views

Populate UITextField by fetching a Core Data string

I'm trying to populate a UITextField with data from a selected cell. When the table is populated, I use the array var intentionsArray: [EIntentions] = [], where EIntentions is my entity in Core Data. Whenever I try to set my text field to a specific index path value in the array, I get an error with...
Anthony DeFallo
1

votes
1

answer
167

Views

looking for duplicate entries using core data

I am looking for duplicated usernames in a login/sign up form using core data. Here is my code: let context = managedObjectContext let entity = NSEntityDescription.entity(forEntityName: 'MyEntityName', in: managedObjectContext) let request = NSFetchRequest() request.entity = entity var Fetcherror: E...
dreamcode
1

votes
1

answer
46

Views

Swift : core Data join entity

I Know that Nsfetchedcontroller does not support multiple entity. But i would like to know what is the efficient way to solve the pb below Lets say i have two entity : catalogue and selectedProduct I am fetching all the entity catalogue to the user so he can select some products the task is: only p...
Wael
1

votes
1

answer
117

Views

Getting filtered data in search bar from json

I'm having a name assigned to my name textfield like so.. for asd in orderDetails { if let jsonStr = asd.value(forKey: 'customerJson') as? String { let data = sdf?.data(using: String.Encoding.utf8, allowLossyConversion: false)! do { if let json = try JSONSerialization.jsonObject(with: data!) as? [St...
v.bw
1

votes
3

answer
531

Views

Swift 3 - Get value from core data

I have a class that will take 2 inputs, Sets and Reps Using prepare(for segue: UIStoryboardSegue, sender: Any?) I passed the values back to the WorkoutViewController.Swift The data is successfully saved since after pressing save barbutton in the SetRepsViewController.Swift the window pops However...
IMan Merzaie
1

votes
1

answer
136

Views

NSFetchedResultsController issue: index 1 beyond bounds, managing custom table view cells

I am stumped with implementing the NSFetchedResultsController as I keep getting errors. I am trying to connect Core Data with the UITableView, and I am not getting to the next step by having UITableView draw out the correct number of rows according to the number of records from Core Data. I get this...
William Chiang
1

votes
2

answer
65

Views

Mac OSX app : Issue Related to NSArrayController NSTableView Core data Adding Record

I have using NSArrayController NSTableView and Core data binding. I have take one button and connect add: method of NSArrayController to its action. On Adding new record TableView added and shows new record. NSArrayController's add: method called Problem : Value is not added into core data (Sqlite...
S. S
1

votes
0

answer
19

Views

Optimise large UITableView load Core Data

in my app, I fetch a list of messages from a web service and store them with Core Data. Over time, the amount of messages grows, and since I want to have all of them offline to be searchable within my app, that's by design. However, the larger the amount of messages in my database, the longer it tak...
Sjakelien

View additional questions