Questions tagged [nsentitydescription]

An NSEntityDescription object describes an entity in Apple Core Data framework. It is available in OS X v10.4 and later and available in iOS 3.0 and later. Its objects are primarily used by the Apple Core Data Framework for mapping entries in the persistent store to managed objects in the application.

An NSEntityDescription object is associated with a specific class whose instances are used to represent entries in a persistent store in applications using the Core Data Framework. Minimally, an entity description should have:

  • A name
  • The name of a managed object class (If an entity has no managed object class name, it defaults to NSManagedObject.)

NSEntityDescription class reference Source Using Entity Descriptions in Dictionaries

NSEntityDescription’s copy method returns an entity such that

[[entity copy] isEqual:entity] == NO

NSEntityDescription supports the NSFastEnumeration protocol. You can use this to enumerate over an entity’s properties, as illustrated in the following example:

 NSEntityDescription *anEntity = ...;
  for (NSPropertyDescription *property in anEntity) {
   // property is each instance of NSPropertyDescription in anEntity in turn
 }


   NSManagedObjectContext *context = <#Get the context#>;

   NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
   NSEntityDescription *entity = [NSEntityDescription entityForName:@"  <#Entity name#>"
inManagedObjectContext:context];
  [fetchRequest setEntity:entity];

   NSError *error;
   NSArray *fetchedObjects = [context executeFetchRequest:fetchRequest error:&error];
   if (fetchedObjects == nil) {
     // Handle the error.
    }
74 questions
1
vote
1 answer

Core Data: Delete the last entity with one to many relationship

In my app i have two entity: Multiple 'Activities' has records inside. When i delete the last ActivityRecord entity in the Activities, i want to delete also Activities entity. I did 'nullify' the delete rule of whichDate but Activities not…
Anamort
  • 341
  • 4
  • 17
1
vote
1 answer

iOS: delete entity with one to many relationship in core data

In my app I have two entity in this way: So, I've two questions: 1- when I delete a "First" entity I want to delete all entity "Characteristics" that belong to first. Do I set the delete rule "Cascade"? 2- If I delete a "characteristics" object…
cyclingIsBetter
  • 17,447
  • 50
  • 156
  • 241
1
vote
1 answer

Getting NSEntityDescription relationships

I have a core data model like so: SALES_REP <--->> CUSTOMER <---->> PURCHASE_AGREEMENT <<------->> PRODUCTS I can get the entity description for the Purchase Agreement and I can get the relationships (toCustomer and…
PruitIgoe
  • 6,166
  • 16
  • 70
  • 137
1
vote
1 answer

CoreData getting attribute type - how to determine if it is a primitive

I'm trying to get all the attributes for an entity and then determine their type - I know I can do something on this line: if(![[thisAttribute attributeValueClassName] isKindOfClass:[NSString class]]) { but how do I check for a BOOL, Float or…
1
vote
2 answers

Core Data Fetch with filter on entity and entities relationship, to many

I need help with a fetch request that filters children where children and parent have a many to many relationship. all the examples I've found are for one to many relationships. Playlists can contain many songs via songs relationship Song can be in…
Augie
  • 1,341
  • 1
  • 11
  • 18
1
vote
5 answers

How to add attributes to an existing Core Data entity (object) programmatically?

I would like to add attributes programmatically to an entity during runtime of my app. Is this something you would recommend doing or can this lead to issues? How would I need to combine NSAttributeDescription and NSEntityDescription? I am familiar…
AlexR
  • 5,514
  • 9
  • 75
  • 130
1
vote
1 answer

EXC_BAD_ACCESS with NSManagedObject

i am trying to insert values in a number of tables (25 to be exact), i am able to insert records in all the table except for one, and that is because of one single Attribute, if i remove that attribute it starts saving the data into the table but…
Kazmi
  • 593
  • 1
  • 6
  • 24
1
vote
1 answer

Why can't I appendString in a for Loop?

I have the following code that I'm attempting to simply loop through an entity and for each NSPropertyDescription name, append it to a Mutable string that I'll be building a further string out of. - (void) createCSV { NSEntityDescription…
1
vote
1 answer

Assigning NSManagedObject properties before insertion doesn't stick

I'm trying to assign the property values of an NSManagedObject before inserting them into the context using a dictionary. The issue I'm running into is that the object values get zero'd out after insertion. I'm working according to the documentation…
1
vote
2 answers

ios core data - copy entity records to another entity

I have 2 entity, Units and BUnits, the Units entity have a data that will be replaced many time, and the BUnits will be the backup of the Units entity before clearing it's data. So, I've created a NSManagedObjectContext instance, then I've retrive…
Scar
  • 3,460
  • 3
  • 26
  • 51
0
votes
1 answer

NSEntityDescription works fine but Analyzer says value never read

I'm puzzled by a remark from Xcode' analyzer. I've searched Stack about it but didn't really find a similar situation. I have a CoreData/SQLite app where the user select a record in a table, gets all the atributes for the entity. then, based on…
user886832
0
votes
1 answer

Core Data: Fetched Results Controller causing over release/crash

I am using core data, and have a UITableViewController which loads the data from core data. This is a modal view and if I load the modal view for the third time, it crashes with EXC_BAD_ACCESS. - (NSFetchedResultsController…
0
votes
2 answers

SIGABRT when trying to add atributes in entity. Core Data on iOs

My app receive SIGABRT when i'm trying to add atributes to my Entity. NSManagedObjectContext *context=[[HistoryDataManager sharedInstance] mainObjectContext]; NSEntityDescription * entityDescription = [NSEntityDescription…
0
votes
1 answer

How to get an entity out of a NSEntityDescription

I have a NSTreeController (treeController) and a CoreData database. I want the entity behind the selected object of my NSTreeController. I use this to get the correct NSEntityDescription: [[[[treeController selectedObjects] objectAtIndex:0]…
Daniel
  • 1,473
  • 3
  • 33
  • 63
0
votes
1 answer

ios - core data: Why does "Entity name must not be nil" sometimes occur?

hey folks. i am writing an ios-app, that contains severals subviews, which can be individually created by a touch of a button. every subview has an instance of 'group', that is an entity saved via core data. 'group' is in to-many relationship with…