Questions tagged [nsmanagedobject]

NSManagedObject is a generic class that implements all the basic behavior required of a Core Data model object. NSManagedObject is available in OS X v10.4 and later and available in iOS 3.0 and later.

From the documentation:

Overview

A managed object is associated with an entity description (NSEntityDescription) that provides metadata about the object, including the name of the entity that the object represents and the names of its attributes and relationships. A managed object is also associated with a managed object context that tracks changes to the object graph.

[...]

Data Storage

In some respects, an NSManagedObject acts like a dictionary—it’s a generic container object that provides efficient storage for the properties defined by its associated NSEntityDescription instance. NSManagedObject supports a range of common types for attribute values, including string, date, and number (see NSAttributeDescription for full details).

Resource

Sample NSManagedObject declaration

In Objective-C:

NSManagedObjectContext *context = [self managedObjectContext];

//create a new managed object
NSManagedObject *newFlight = [NSEntityDescription insertNewObjectForEntityForName:@"FlightEvent" 
        inManagedObjectContext:context];

In Swift:

let newFlight = NSEntityDescription.insertNewObjectForEntityForName("FlightEvent", inManagedObjectContext: managedObjectContext)
1597 questions
0
votes
0 answers

Best practice for NSManagedObjectContext + thread + singleton

I have an app use core data with allot of relationShip, let say i have models A, B and C, some operation must be in a separated thread, i create 2 singleton S1 and S2 (and the AppDelegate one having his Context): S1 manage A and B: it have a…
Red Mak
  • 1,176
  • 2
  • 25
  • 56
0
votes
1 answer

NSPopupbutton combining two values for Content. Perhaps similar to DisplayPattern

Id like to use a NSPopupbutton to show a list. each element in the list combine two attributes from an NSManagedObject. "firstname, userid" I'd rather not add a transient attribute, since that dirties the business logic. Is there a simple method of…
0
votes
1 answer

Subclass of custom class that needs to subclass NSManagedObject

So here's my dilemma. I'm dealing with legacy code and trying to simplify and reduce a huge amount of redundancy in the code base. Here's the crux of the matter. I'm trying to consolidate two very similar classes into a superclass/subclass…
Rymnel
  • 4,515
  • 3
  • 27
  • 28
0
votes
0 answers

iOS Core Data // NSOrderedSet and SIGABRT

I recently had to modify the data model of a project I didn't started. I just added the attribute "ordered" on some entities, and regenerated the whole thing in classes, about 10. The issue is, I'm now constantly getting a SIBAGRT exception, and I…
Thomas Pujolle
  • 155
  • 1
  • 1
  • 11
0
votes
0 answers

Deleting related NSManagedObjects from custom NSManagedObject class

I have 2 custom NSManagedObject subclasses: Patient and ToDoItem. There is a one-to-many relationship from Patient to ToDoItem. Following are the properties of the Patient subclass: @property (nonatomic, strong) NSSet *toDoItems; @property…
Christian R
  • 1,545
  • 3
  • 13
  • 17
0
votes
0 answers

Core Data Crash during Save without error. Only one Context and only main thread

I'm simply trying to delete three nsmanagedobject from an entity, as i already do in other application,where all went ok. This time core data seems to crash during save, there's no error, i'm using the app delegate context in all the app, so i think…
0
votes
1 answer

Make a relationship with one object already exists

The user must create a family in AllFamille. In a second view the user must create a product in AllProduit. While creating, the user must choose the family created before. AllFamille and AllProduit are two different entities. How to create a…
0
votes
1 answer

Core Data: How to update an NSArrayController immediately after adding an NSManagedObject?

I am adding an instance in core data. The entity is represented by an NSArrayController. I would like to access the newly added instance through the controller. A "Skill" instance is added and then I try to access it through selectAddedObject as…
Carelinkz
  • 936
  • 8
  • 27
0
votes
0 answers

core data - context don't save on second view

Ill try to explain my situation correctly. I got 2 views. On my first view i got a table what lists Events. If i touch a cell, I get my EventOverviewView. So i have different behaviors on each view: FirstView (List of Events): if I touch and hold on…
SaifDeen
  • 862
  • 2
  • 16
  • 33
0
votes
1 answer

CoreData predicate and fetch input takes way to long

I have this piece of code: -(void)createArtistsFromArray:(NSArray*)jsonAttrArr { NSError *fetchError = nil; if (jsonAttrArr) { for(NSMutableDictionary *dic in jsonAttrArr) { NSFetchRequest *fetchRequest =…
Jakub
  • 13,712
  • 17
  • 82
  • 139
0
votes
1 answer

NSMangedObject not letting access an objects data

I am using CoreData and I have an NSManagedObject of type Thing. When I set a breakpoint I can console "po aThing" and it shows the data stored. { thingID = 5181c56063ab02c4d1000016; distance = "2.075121"; lat = "37.815834"; lng =…
jdog
  • 10,351
  • 29
  • 90
  • 165
0
votes
2 answers

Do NSManagedObjects have file urls?

I have an NSManagedObject *obj written to an NSManagedObjectContext. It has key/values which include a "data" key that returns a ~5-10mb size NSData *value. How do i get the url / file path where value is stored?
user592419
  • 5,103
  • 9
  • 42
  • 67
0
votes
1 answer

nsmanagedobject relationship 0

Given a Core data app. I'd like to prevent a deletion if a relationship is not empty. The best method seems to be with validateForDelete. Yet, when quering the size of the relationship it returns 0. The following sets all return a non-nil object…
Gabe Rainbow
  • 3,658
  • 4
  • 32
  • 42
0
votes
2 answers

is there a generic way to get a set of NSManagedObjects that where inserted or deleted from a Core Data relationship?

For example, say I have a User managed object with a friends relationship that goes User<->User many-to-many. Now let's say for some user a, 2 users x and d are already in a's friend relationship. But then: I add users b and c to friends. I…
SaldaVonSchwartz
  • 3,769
  • 2
  • 41
  • 78
0
votes
0 answers

nsmanagedobject core data many-to-many relationship fault

In my CoreData app, all inverse many-to-many relationships have a relationship fault. -- observed using NSLog(@"%@", [self description]) . The fault appears after data is saved and subsequently opened. The relationship delete rule might be the…
Gabe Rainbow
  • 3,658
  • 4
  • 32
  • 42