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
2 answers

Working with several NSManagedObject

My question is very simple. I have something like 10 different entities in CoreData, all with the same attributs (name, description ...). To access these attributes i doing in this way: MyEntity *entity=...; MyEntity2 *entity2=...; ... MyEntity10…
Bobyblanco
  • 123
  • 12
0
votes
2 answers

data: when return fetch request objects from method

When I converted my application to new technology ARC (automatic reference count) there is a fault, when I fetched from CoreData. Below is my method and calling for it: NSArray *userinfo =[self checkData:self.username]; //This return fault data in…
wod
  • 812
  • 1
  • 10
  • 23
0
votes
1 answer

Core Data Problems with saving changes in NSManagedObjectContext

I am experiencing problems with how I handle my Core Data NSManagedObjectContext. I can create NSManagedObject in my NSManagedObjectContext, but I failed to save the value. Here's what I got: _lesson.title = _titleField.text; int priority =…
Shane Hsu
  • 7,937
  • 6
  • 39
  • 63
0
votes
2 answers

Passing reference to NSManagedObject's attribute to a background thread

What I'm trying to do is following: Product *product = [fetchResult lastObject]; NSString *productID = product.atProductID; dispatch_async(queue, ^(void){ // Something with productID like NSLog(@"productID is %@", productID); }); Is it safe to do…
0
votes
1 answer

Preferred method for storing data fetched from Core Data (iOS)

Let's say I'm building an app that displays a UITableView of contacts. The user's contacts are stored on a remote server. I fetch the user's contacts from the server and store them in Core Data. My UITableViewController loads and I fetch an array of…
Jeremy Z
  • 106
  • 2
  • 8
0
votes
2 answers

Managed Object in Core Data entity causing "is not key value coding-compliant for key" error

I'm pretty new to Core Data, and objective-c. I have been up and down the Core Data documentation, and don't know what I'm doing wrong here. At runtime, I'm getting the following error when adding the NSManagedObject "ReportItem" to the…
RoboArch
  • 453
  • 1
  • 6
  • 17
0
votes
2 answers

Issue With NSManagedObjectID when using as property

I'm trying to fetch object by its unique object, and for that I'm saving id of inserting object which I will use to fetch it back, here is my code. @implementation UserInfoDOA @synthesize…
BaSha
  • 2,356
  • 3
  • 21
  • 38
0
votes
0 answers

Reload my view controller after Core Data delete operation

I have one summary page controller where I display all users from database file. I'm using Core Data environment. In this page I have one button to delete all users from db. This is working fine but I'm not able to reflect those changes in current…
BaSha
  • 2,356
  • 3
  • 21
  • 38
0
votes
1 answer

Value of an NSManagedObject's property newly created at every get?

Consider the following code NSManagedObject *o = ... ; o.myProperty = [NSDate date]; NSDate *a = o.myProperty; NSDate *b = o.myProperty; BOOL identical = (a==b); BOOL equal = [a isEqual:b]; running this on my iPhone with iOS 5 sets identical =…
Tom
  • 260
  • 4
  • 13
0
votes
1 answer

iOS Multi-threaded core-data app not merging changes

I have an iOS app which is accessing a core data sql database from two threads. Thread A (the main UI thread) updates a core data record, and Thread B then attempts to read from the Entity collection that Thread A has just updated. Trouble is,…
Journeyman
  • 10,011
  • 16
  • 81
  • 129
0
votes
1 answer

Adding ivars to NSManagedObject subclass

When I create an entity using core data then generate a subclass of NSManagedObject from it I get the following output (in the .h): @class Foo; @interface Foo : NSManagedObject @property (nonatomic, retain) NSString *name; @property (nonatomic,…
user843337
0
votes
1 answer

Modify records in core data without edit mode

I´m having trouble re-saving records in my core data, and i was hopping someone could help me understanding what am i missing here: When i want to save a record, i have my "product" tableview with the code below: -…
Japa
  • 632
  • 7
  • 30
0
votes
0 answers

Why NSManagedObjectID doesn't change after I save the data?

I try to get stuff from the web in a different thread. I used a new managedobject context. I set the managedobjectcontext of the main thread as the parent. I save the new managedobject context I collect the managedobjectid (which should now be…
user4951
  • 32,206
  • 53
  • 172
  • 282
0
votes
1 answer

Core Data - One to Many relationship with object(one) and UIImages(many), storing and fetching

I aim to build a app with the object of: - Request(contains an unique id, customer name, phone, email, a brief summary of request info, a list of images(store in NSMutable Array) My Core data contains: Request Image For my request object, I…
phil88530
  • 1,499
  • 3
  • 19
  • 27
0
votes
1 answer

How to store a reference of an audioPlayer instance in core data?

My goal is to store the reference of an audioPlayer instance in core data in that way, that i can use properties on that entry later. like this: -(void)didTapButton { if (!self.sound.audioPlayer.playing) { [[NSNotificationCenter…
rockstarberlin
  • 1,853
  • 1
  • 18
  • 31
1 2 3
99
100