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
1 answer

Remove and add store from Core Data

I'm storing some sensitive information like passwords etc. in Core Data. I want that my app encrypts the entire SQLite database (it's not very big, < 1 MB) whenever the apps goes into the background or terminates. I figured out the encryption thing…
el3ktro
  • 167
  • 2
  • 9
0
votes
1 answer

How to determine if NSManagedObjectID is permament?

I want to make sure that an NSManagedObject that I am working with has a permanent NSManagedObjectID. I know that it only is made permanent on [NSManagedObjectContext save:] or [NSManagedObjectContext obtainPermanentIDsForObjects:error:]. However,…
Jason
  • 14,517
  • 25
  • 92
  • 153
0
votes
0 answers

NSPredicate created within subclass of NSManagedObject crashes

When I create a predicate like this, from outside a subclass of NSManagedObject, it works just fine: CNSTag *aTag = ... _predicateForMatchingObjects = [NSPredicate predicateWithFormat:@"ANY tags == %@", aTag]; However, when I try to provide a…
pickwick
  • 3,134
  • 22
  • 30
0
votes
1 answer

iOS - Core data auto generated model - unrecognized selector

I have a basic Core Data model which look like this : I auto-generated data model files and it's give me something like that : BSStudent.h // // BSStudent.h // #import #import @class…
Yaman
  • 3,949
  • 4
  • 38
  • 60
0
votes
1 answer

iOS - Memory Management advice when passing ManagedObjectContext To Other Views

I have a pretty hefty application so far, and it is heavily tied in with Core Data. I pass a NSManagedObjectContext (along with NSManagedObjects themselves) to other views. Everything I've read shows that, for the view you are passing the Managed…
0
votes
1 answer

Best way to preload nsmanagedobjects

i want to store some managed objects as to make searching later on easier, what is the best way to do that? (So that it survives exiting the app) I am thinking user defaults (but im not sure if you can store managed objects like this) Or some sort…
William Falcon
  • 9,813
  • 14
  • 67
  • 110
0
votes
1 answer

sort array of objects by string

I have an array of managedobjects. Each has a title (name). I want to sort these NOT alphabetically, but by the one that matches a certain string the closest (the search query) How would I do this? Thanks
William Falcon
  • 9,813
  • 14
  • 67
  • 110
0
votes
2 answers

NSManagedObject attributes not being updated on parent NSManagedObjectContext

So I have two NSManagedObjectContext objects. A parent context and a child context. I have a few NSManagedObjectModels and I'm able to create/edit/destroy 4 out of 5 of them. No problem. I can insert objects on the child context then save it and…
0
votes
2 answers

How to delete an object from RestKit managed object store

I'm using RestKit 0.2 to get a JSON file from my server and map the objects to my CoreData stack (analog to the TwitterCoreData example). In the first request, I get the following result: Artist1, Artist2, Artist3. In the second request, one artist…
TimE90
  • 3
  • 3
0
votes
2 answers

better way of removing double (NSManagedObjects) from NSArray (also logic flaw)

I made the following method to remove doubles, however it doesn't fully work. Any suggestions? Thank you for the help, -(NSMutableArray*)removeDuplicateCars:(NSMutableArray*)array{ NSMutableArray *noDuplicates =[[NSMutableArray alloc]init]; …
William Falcon
  • 9,813
  • 14
  • 67
  • 110
0
votes
1 answer

get relationships from an NSDictionaryResultType

I have a results array containing the fetch results from core data. It is an array of Dictionaries (according to NSDictionaryResultType). The object I fetch is a car, car has name,make,model,color (which I can see all in the array). However car…
William Falcon
  • 9,813
  • 14
  • 67
  • 110
0
votes
1 answer

creating core data objects with same attribute duplicate entry?

I am wondering how this works, if I create a Car object, and there is a relationship called toParts (that has a set of all car parts for this car), and then I create another car, will it duplicate the toParts set? add to core data: car a = (toParts…
William Falcon
  • 9,813
  • 14
  • 67
  • 110
0
votes
1 answer

JSON pages only accessing the first page xcode

i am getting 10,000 records returned from a JSON query, and it is split into 102 pages with roughly 100 objects per page. The first 100 items are loaded fine, but then it stops loading more. How do I get it to go to the next page? How is this…
William Falcon
  • 9,813
  • 14
  • 67
  • 110
0
votes
1 answer

Issue loading subentities to mangedobject in coredata

I think this is wrong, it only loads one car part: This methods takes two arrays one with car names, one with parts, creates a new car, and adds car parts to it, then saves the car to core data. (currently does not work this way) for (int i=0;…
William Falcon
  • 9,813
  • 14
  • 67
  • 110
0
votes
1 answer

array of NSManagedObjectID from NSFetchedResultController

I have a data set displayed in a UICollectionviewController, which I access using [fetchedResultsController objectAtIndexPath:indexPath] Using a segue, I move onto a modal scrollview+uipageController, where each data is displayed one after the…
Alex
  • 1,581
  • 1
  • 11
  • 27
1 2 3
99
100