Questions tagged [nsmanagedobjectmodel]

An NSManagedObjectModel object describes collection of entities that you use in your application. It is available in OS X v10.4 and later and available in iOS 3.0 and later .

56 questions
1
vote
1 answer

Need generic FetchedResultsController builder (Swift)

I created a method to build an frc: private func buildFRC(entity: T, sortKey: String) -> NSFetchedResultsController? { let fetchRequest: NSFetchRequest = T.fetchRequest() let sortDescriptor1 =…
user8384082
1
vote
1 answer

Finding the entities of a CoreData model at runtime

I have an macOS app being developed in Xcode (8.3.2) in SWIFT. I have a CoreData model with a number of entities and an identifier (myidentifier). I want to be able to identify the entities of the model programatically at runtime so that I can…
1
vote
1 answer

What is the criteria of compatibility between a store metadata and a managed object model?

My app uses CoreData framework and I want to check compatibility between a store metadata and a managed object model. I do it standard way: BOOL isModelCompatible = [model isConfiguration:nil …
Andrey Chernukha
  • 21,488
  • 17
  • 97
  • 161
1
vote
1 answer

Usage NSManagedObject model in code

I have a User model class (generated by XCode with Swift): @objc(User) class User: NSManagedObject { } And it's extension: extension User { @NSManaged var id: NSNumber? @NSManaged var firstName: String? @NSManaged var lastName:…
Viktor
  • 1,020
  • 1
  • 9
  • 22
1
vote
1 answer

Does it make sense to have a primary key attribute in Core Data in iOS 9?

In iOS 9, I can specify certain attributes in an entity to be unique constraints to prevent managed objects with the same unique constraints to be created. Each NSManagedObject has its own ObjectId but maintained internally by Core Data and cannot…
1
vote
1 answer

change NSManagedObject parent entity in another version

Is there any good way to change parent entity of an NSManagedObject in another version? Lets say on model version 1.1 I got: anObject - with no parent entity in version 1.2 i want to make it inherit from object - a parent class that already…
1
vote
0 answers

Core Data "unable to load class named..."

I'm learning Core Data and I have problem. I tried many things but xcode always tell me: 2015-04-25 21:20:44.057 CoreData2[8979:202376] CoreData: warning: Unable to load class named 'Contacts' for entity 'Contacts'. Class not found, using default…
Lachtan
  • 4,803
  • 6
  • 28
  • 34
1
vote
0 answers

Core Data - Migrating to new Model Name

I have an app in the store now that I am updating. I did a lot of Core Data changes, including changing the name in both 'lazy var managedObjectModel: NSManagedObjectModel' and 'lazy var persistentStoreCoordinator:…
1
vote
1 answer

swift_dynamicCastClassUnconditional issues in swift

I have the following NSManagedObject in swift: import Foundation import CoreData public class User: NSManagedObject { @NSManaged public var first_name: String @NSManaged public var last_name: String } I have a class which provides the…
KVISH
  • 12,923
  • 17
  • 86
  • 162
1
vote
3 answers

After updating Core Data model I receive a "unrecognized selector" error

I have Core Data model and it work fine, but I need to add new attribute. I click on my .xcdatamodel and go to Editor/Add Model Version. Now I add new attribute and add this in .h and .m file. When I run application it give me an error…
Marko Zadravec
  • 8,298
  • 10
  • 55
  • 97
1
vote
1 answer

Crash when reusing NSFetchRequest across multiple contexts

Edit: The original title for this thread was "Crash when creating a second managed object model", but the problem was solved and the problem turned out to be as described in the title above. TL;DR: Do not reuse NSFetchRequests across multiple…
Léo Natan
  • 56,823
  • 9
  • 150
  • 195
1
vote
2 answers

Relational Database Design (E-Commence) - Core Data

In my e-commence app (for café/restaurants) I currently have the following database structure. The cart is the shopping cart, in which you can add products, a temporary place before the products/an order is sent to the server. The ProductCart is a…
1
vote
1 answer

Core data not working on device but fine on simulator

I am using core data for my application.It works fine on simulator but not retreiving the details on real device.Device is of iOS6.1.This is the code i am using: - (NSManagedObjectContext *) getCurrentMangedContext { NSURL *modelURL = [[NSBundle…
iOS Developer
  • 1,723
  • 2
  • 16
  • 47
1
vote
1 answer

Get NSManagedObjectId when saving object

How does one retrieve the NSManagedObjectID when saving an object to Core-Data? I have a series of objects to save to Core-Data and I need to have each ones objectID as I am saving on another thread. I would then like to pass this array to the main…
some_id
  • 29,466
  • 62
  • 182
  • 304
0
votes
2 answers

How to map model for NSManagedObject?

When I try to do this, the model is stored in the NSManagedObjectContext if I use the context, and without it it throws an error, but I'm not expecting the same result. Is there an easy way to implement this? class WordDal: NSManagedObject { …