nsmanagedobject

Mystery Key Value Coding Key

二次信任 提交于 2019-12-12 03:09:29
问题 I'm attempting to load data from an undocumented API (OsiriX). Getting the NSManagedObject like this: NSManagedObject *itemStudy = [[BrowserController databaseOutline] itemAtRow: [[BrowserController databaseOutline] selectedRow]]; works just fine. But getting the NSManagedObject like this: seriesArray = [_context executeFetchRequest:request error:&error]; NSManagedObject *itemSeries = [seriesArray objectAtIndex:0]; Generates an error when I call [itemSeries valueForKey:@"type"] 2010-05-27 11

Core Data - Re-saving Object in didSave

…衆ロ難τιáo~ 提交于 2019-12-12 02:06:31
问题 I have to check for certain properties after saving the object to the database (I need to make sure first that it's saved on disk). So, I thought that the didSave method of NSManagedObject is the best place to do so. However, after checking for these properties and changing some of them, I want to re-save the object. So, I call the managed object context to save the object one more time . (I made heavy testing to make sure I won't get into an infinite loop). Now, the problem is the managed

How can I test if an attribute of a CoreData object is null?

巧了我就是萌 提交于 2019-12-12 02:05:59
问题 I want to test if an NSNumber attribute of a NSManageObject Subclass has been set or not. Note, that the attribute is of NSNumber / Integer16 I have tried several approaches but none worked (these below always evaluate to false): // Note: patient.zyklus_laenge is of NSNumber (Integer16) // does not work id value = patient.zyklus_laenge; if (value == [NSNull null]) { self.zyklusLaengeTextField.text = [NSString stringWithFormat:@"%d", 28]; } else { self.zyklusLaengeTextField.text = [NSString

NSManagedObject with Category and Delegate

给你一囗甜甜゛ 提交于 2019-12-12 01:28:53
问题 I created a NSManagedObject called MapState. I then created a category for it to call some methods and store some extra variables. .h #import "MapStateDB.h" @protocol MapStateDelegate; @interface MapStateDB (MapState) @property (weak, nonatomic) id <MapStateDelegate> delegate; -(void)selectedSceneObject:(SceneObject *)sceneObject; -(void)removeDisplayedScene; @end @protocol MapStateDelegate <NSObject> -(void)displayScene:(SceneDB *)scene inState:(NSString *)state; -(void)removeScene:(SceneDB

Core Data, how can i find and delete managed objects effectively

北城余情 提交于 2019-12-12 00:28:28
问题 My app sends a get request to a server with a date (date of last update) to update its content (2 entities in core data, no relationships, all attributes are strings)... most of the time it only receives new content but sometimes it also receives the old content that needs to be updated instead of just inserted. 1 table is pretty straight forward I just get the ids (id from server not form core data) of the items that are going to be updated in an array and I make a fetch of those items and

NSManagedObjectContextDidSaveNotification not triggered in iOS 7

余生颓废 提交于 2019-12-11 21:12:04
问题 I have a situation where I make some changes to the properties of a NSManagedObject in main thread. It belongs to the main ManagedObjectContext of the app. My app does has threading enabled which downloads data, each thread has it's own ManagedObjectContext created from the most recent state of a single PersistentStore throughout the application. I am implementing NSManagedObjectContextDidSaveNotification so that any changes in the MOC is merged back to the main thread's MOC too. Below is the

Why is the class wrong for NSFetchRequest?

一笑奈何 提交于 2019-12-11 20:36:42
问题 I am working with an undocumented API (Osirix) and I have a sister-question to the one I posted here. I am having trouble loading objects from a managed object context. With loading from API, using their instance of _context and _model 2010-05-28 14:05:13.588 OsiriX[44012:a0f] Entity: Study 2010-05-28 14:05:13.589 OsiriX[44012:a0f] EntityClassName: DicomStudy 2010-05-28 14:05:13.589 OsiriX[44012:a0f] ClassName: DicomStudy With loading from Fetch Request (and my own instance of _context, and

Issue loading subentities to mangedobject in coredata

…衆ロ難τιáo~ 提交于 2019-12-11 16:52:22
问题 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; i<[massiveArray count]; i++) { //create a new car and part Car*newCar =(Car*)[NSEntityDescription insertNewObjectForEntityForName:@"Car" inManagedObjectContext:[self managedObjectContext]]; CarPart *part =[NSEntityDescription

Storing NSManagedObjectID vs NSManagedObject

*爱你&永不变心* 提交于 2019-12-11 16:43:50
问题 I have an app where users can select a specific theme for locations to display. I store the selected theme objectID in NSUserDefaults so that when the app restarts, the selected theme will still be intact. Throughout the app I reference back to this selected theme. I currently have a class variable to hold the objectID, however I sometimes need to retrieve properties of the object itself (i.e. the name property). To do this I retrive the object from core data and then access my value. I'm

What would be a thread-safe way to save a context form Core Data?

耗尽温柔 提交于 2019-12-11 12:47:14
问题 I have a NSOperationQueue set to NSOperationQueueDefaultMaxConcurrentOperationCount . It is filled with NSOperation objects (nothing weird so far). I subclassed the NSOperation to do some background tasks. Download data from the internet. Parse the data so I can read it. Create a NSManagedObject: [NSEntityDescription insertNewObjectForEntityForName:@"Channel" inManagedObjectContext:context]; Save it with the context. [managedObjectContext save:&error] I like this all to happen in the