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

Execution_BAD-ACCESS when deleting data

I am showing data in table view using NSFetchedResultsController. Now when data reaches from server I need to delete all data present in the sqlite database. Now when I delete data from database using given below code it sometime crashes (not…
Iqbal Khan
  • 4,587
  • 8
  • 44
  • 83
0
votes
1 answer

coredata-MO modification reflecting for each existing records in PS

I found many tutorials & articles over internet for core data but I am making sample app that is realtime & more useful to beginner. You can find the sample code here. The core data structure is like this. I make entries to artists, albums &…
0
votes
1 answer

Duplicate copies of NSManagedObjects

I have a number of View Controllers that need to show data from a Core-Data store. Each of them fetch managed objects from the same context but for some reason the number of managed objects increases when more than once VC has made a fetch? Can the…
some_id
  • 29,466
  • 62
  • 182
  • 304
0
votes
1 answer

CoreData one-to-many relationship issues

I am working with coreData one -to many relationship. For example folder - file. So what I want to do is that take a file from one folder and copy it to another folder. So for example folder A B file a b file c d Now I want to copy…
0
votes
1 answer

NSManagedObject becomes null

Im using a NSManagedObject as an attribute within my ViewController, declared like this: @property(retain, nonatomic)NSManagedObject *person; Im propagating the content of a fetch to a UITableView, when the user taps the contact he is looking for,…
subharb
  • 3,374
  • 8
  • 41
  • 72
0
votes
1 answer

Set one particular property of all objects in an NSManagedObjectContext at the same time, and update immediately

Let's say I load in 1,000 objects via Core Data, and each of them has a user-settable Favorite boolean. It defaults to NO for all objects, but the user can paw through at will, setting it to YES for as many as they like. I want a button in my…
Luke
  • 9,512
  • 15
  • 82
  • 146
0
votes
1 answer

NSManagedObject "on update" method?

I want to set update date to NSManagedObject each time object is changed. Is there method similar to awakeFromInsert ?
Nik
  • 9,063
  • 7
  • 66
  • 81
0
votes
0 answers

using array of custom NSManagedObject in another NSManagedObject

I have a "Record" NSManagedObject class and "Title" NSManagedObject, Record object have 2 properties, title and laTitle both are of type "Title" ManagedObject. and also need this "Title" object as other NSManagedObjects which have no relation to the…
Friendtam
  • 311
  • 4
  • 11
0
votes
1 answer

NSManagedObject stop updating

In my model I have: Product <<---> Order Product Attributes: productName productPrice Product Relationships: order Order Attributes: orderName salePerson Order Relationships: products Imagine I have a Product (call it…
Alish
  • 133
  • 3
  • 13
0
votes
1 answer

Core Data unrecognized selector error

I am using Core Data to save some strings. I have the following class called Results Results.h #import @interface Results : NSManagedObject @property(nonatomic, retain) NSString *lessondate; @property(nonatomic, retain)…
Hassan Mahmood
  • 1,591
  • 2
  • 12
  • 24
0
votes
2 answers

CFBitVector stored as an attribute to a coredata object

I am attempting to create a fingerprint for an object in coreData, and want to set it as attribute to an object. I figured CFBitArray is the way to go. I am trying to figure out how to save this per object: Here is an example Object…
William Falcon
  • 9,813
  • 14
  • 67
  • 110
0
votes
1 answer

How to store an ALAsset object as an attribute of a NSManagedObject

My application allows user to upload photos from the camera roll. Since I use NSManagedObject to manage the uploading photos, I want to store an ALAsset object as an attribute of NSManagedObject. I have tried to set the attribute type to…
ShengHuaWu
  • 140
  • 8
0
votes
3 answers

Getting string from NSManagedObject

When I try to get a string value from an NSManagedObject, I get this (entity: Entity; id: 0x1e041c30 ; data: { number = "
Chris Loonam
  • 5,735
  • 6
  • 41
  • 63
0
votes
1 answer

Core data debugger hangs at assigning value to entity

I have a core data entity to which I am trying to assign relationship from another entity. Please refer the code below #define kId @"id" -(NSArray *)fetchObjectsForEntityName:(NSString *)entityName withPredicate:(NSPredicate *)predicate { …
iSee
  • 604
  • 1
  • 14
  • 31
0
votes
1 answer

Saving one-to-many relationship CoreData

I am having troubles with the relationship I have setup in CoreData. Its one to many, a Customer can have many Contact, these contacts are from address book. My model it looks like this: Customer <---->> Contact Contact <----->…
Paulo Rodrigues
  • 5,273
  • 7
  • 35
  • 58