nsmanagedobject

Get property class giving the property name

馋奶兔 提交于 2019-12-11 03:04:51
问题 What I need I have a bunch of classes generated from my data model that inherit from NSManagedObject. I need a way to get, for any of theses classes, a dictionary of a string of a property name as the key, and the string of it's type as the value, for every property name passed in an array. Or better, in code: // what I have - generated code @interface ClassA : NSManagedObject @property (nonatomic, retain) ClassX *propX; @property (nonatomic, retain) ClassY *propY; @end @implementation ClassA

CoreData: Unable to load class for entity

风格不统一 提交于 2019-12-11 02:57:09
问题 I'm having an issue using relationships in Core Data. I created my data model including the following entities: User, Conversation, Message, Participant - each containing a one-to-many relationship with the entity following it. I generated the classes for each entity using Editor -> Create NSManagedObject Subclass, and it correctly created the .Swift files for each class. The project builds, but when attempting to create and save a new user I get the following error: 2014-12-01 12:31:28.450

Description of NSManagedObject shows values, but accessing them shows NaN?

孤人 提交于 2019-12-10 23:15:20
问题 I have found here an excellent solution for creating relationships when migrating a model. I came across an odd problem within the model itself. -(BOOL)createRelationshipsForDestinationInstance:(NSManagedObject *)dInstance entityMapping:(NSEntityMapping *)mapping manager:(NSMigrationManager *)manager error:(NSError *__autoreleasing *)error { NSError *superError = nil; BOOL ismappingSuccess = [super createRelationshipsForDestinationInstance:dInstance entityMapping:mapping manager:manager error

NSManagedObject to JSON

不羁岁月 提交于 2019-12-10 21:49:27
问题 I have an entity class called catObras, and it inherits from the class NSManagedObject. What I want to do is pass it trough a web service (POST) in JSON form. If I sent the object I receive this: <catObras: 0x6d879f0> (entity: catObras; id: 0x6d859b0 <x-coredata://41B60B06-248C-488D-A14C-894E04D0395F/catObras/p2> ; data: { Reporte = "<relationship fault: 0x6d9dc40 'Reporte'>"; calendarioVisitas = "<relationship fault: 0x6dac2c0 'calendarioVisitas'>"; catFondosInversion = "<relationship fault:

Parent MOC get changes with empty data from child MOC

空扰寡人 提交于 2019-12-10 21:48:35
问题 I'm stuck on this problem with CoreData and Parent-Child MOCs: when adding objects to child MOC, saving them and saving the parent MOC all the objects gets their attributes reset to defaultValue. I pasted here the logs from the two MOCs, specifically are the "stringAttribute" and "date" attributes that in these log are reset. I searched for this problem everywhere but i didn't find anything, I also looked at lots of implementation of Parent-Child MOCs but I can't figure out what I'm doing

Trying to implement master-child Managed Object Context when doing mass delete in Core Data

孤街醉人 提交于 2019-12-10 11:37:00
问题 I am working on a project where I am doing a mass delete of a number of NSManagedObjects (MO) that I retrieve from Core Data. When I iterate through this collection of MO's, I am also retrieving OTHER MO's by calling a fetch method DURING the iteration of the initial collection of MO's. If during this iteration process, an object is found from the fetch request, the MO is deleted. I realize that this is a poor design of the architecture, as these MO's should in fact be having inverse

“Error: this process has called an NSArray-taking method…” when iCloud pushes managed objects

人走茶凉 提交于 2019-12-10 10:18:52
问题 For every managed object that is sent via iCloud update, this warning/error is sent to the console: *** ERROR: this process has called an NSArray-taking method, such as initWithArray:, and passed in an NSSet object. This is being worked-around for now, but will soon cause you grief. My managed objects are Clients and have a one to many relationship with assessments as shown below. class Client: NSManagedObject { //other NSManaged vars are here @NSManaged var assessment: NSOrderedSet } Judging

insertNewObjectForEntityForName:inManagedObjectContext: returning NSNumber bug?

纵饮孤独 提交于 2019-12-10 02:20:50
问题 I'm relatively well versed in CoreData and have been using it for several years with little or no difficulty. For the life of me, I can't figure out why insertNewObjectForEntityForName:inManagedObjectContext: is all of a sudden returning some sort of strange instance of NSNumber. GDB says the returned object is of the correct custom subclass of NSManagedObject, but when I go to print a description of the NSManagedObject itself, I get the following error: *** -[NSCFNumber objectID]:

avoid duplicate results on Core Data fetch

落爺英雄遲暮 提交于 2019-12-09 13:51:07
问题 I have a subclass of the CoreDataTableViewController (subclass of UITAbleViewController dome by the people on Stanford done to link CoreData and TableViews). On this Class, I want to perform a fecth, sorting by an attribute called "definition" and the code which executes it is the following: - (void)setupFetchedResultsController{ NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:self.entity]; request.propertiesToFetch=[NSArray arrayWithObject:@"definition"]; request

ViewContext not receiving updates from newBackgroundContext()

风格不统一 提交于 2019-12-08 16:43:21
问题 There is a similar question in stack overflow already but it doesn't work for me. There is a use case in my application where I have to observe the database changes to perform some operation. To receive updates I subscribed to NSManagedObjectContextObjectsDidChange notification (for ViewContext) and also I turned on automaticallyMergesChangesFromParent . But, if I update or delete the object on some other context (using newBackgroundContext() ), I don’t receive object did change notification