nsmanagedobject

NSManagedObjectModel versionIdentifiers

僤鯓⒐⒋嵵緔 提交于 2019-12-04 01:56:09
问题 The documentation for NSManagedObjectModel -versionIdentifiers says, The Core Data framework does not give models a default identifier, nor does it depend this value at runtime. For models created in Xcode, you set this value in the model inspector. I am not sure, but I think that setting version identifiers might help me as I go about coding model migration policy classes. Does anyone know how one might set these identifiers in Xcode? I have poked around a fair bit without success. Thanks.

Set auto increment in Core data iOS

我是研究僧i 提交于 2019-12-04 00:02:58
I am using Core Data, and want to set an auto_increment ID as one of the fields which will be unique. Is it possible to set auto_increment in iOS using core data? Can anyone help me with a small example of how to implement this? Below is the code through which I am inserting records in database. In the first field "id", i want to set it as auto_increment and not manually insert it. - (NSManagedObjectContext *)managedObjectContext { NSManagedObjectContext *context = nil; id delegate = [[UIApplication sharedApplication] delegate]; if ([delegate performSelector:@selector(managedObjectContext)]) {

avoid duplicate results on Core Data fetch

∥☆過路亽.° 提交于 2019-12-03 20:56:13
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.returnsDistinctResults=YES; NSPredicate *predicate1 = [NSPredicate predicateWithFormat:@"%K != nil", @

Is it possible to override getters and setters for @dynamic properties in an NSManagedObject subclass?

蹲街弑〆低调 提交于 2019-12-03 18:35:48
问题 So, my scenario is this: I have an NSManagedObject subclass in my iOS application, and as a property I want to store the contents of an MKPolygon object. The way I've decided to go about this (and whether it's valid is perhaps a different question) is to declare the polygon property as a transformable object, then store an NSArray containing the polygon's points (as an NSValue object). To this end, I've written a couple of convenience class methods on my model object: + (NSArray *

Duplicate symbol error when adding NSManagedObject subclass, duplicate link

青春壹個敷衍的年華 提交于 2019-12-03 18:32:36
问题 I was trying to create NSManagedObject subclasses (2 related entities) automatically in Xcode. They are generated like this: However, before I do anything further, when I tried to build and run it, a link error occur, as shown: duplicate symbol _OBJC_CLASS_$_Photo in: /Users/Kefeng/Library/Developer/Xcode/DerivedData/Photomania-aellrakjngugnzcgrleiytvrfvyt/Build/Intermediates/Photomania.build/Debug-iphonesimulator/Photomania.build/Objects-normal/x86_64/Photo+CoreDataClass.o duplicate symbol

Core Data - Iterating through the attributes of a NSManagedObject

你说的曾经没有我的故事 提交于 2019-12-03 17:02:53
问题 I am a noob at core data, so here goes. I have a core data object, for example student. The student has mane attributes, like name, age, dob, address, and so on. Now I need to display all these attributes into a table view. Is there any easy way to iterate through the object student? Or do I have to convert the data into some type of dictionary? If I need to convert it to a dictionary is there any support for it? Or do I have to write the function my self. Many thanks for your help, Stephen

Core Data saving problem: can't update transformable attribute (NSArray)

倖福魔咒の 提交于 2019-12-03 16:11:17
I have a strange problem in my Core Data app. I have three entities in my app, but today I found a problem with one of them. My problematic entity is called Invoice and it has many attributes, including Products . It's encoded NSArray of NSDictionaries (via default NSValueTransformer). Everything works fine - i create my invoice, its client, its products, etc. Everything works. But , when I choose my invoice from a list and then try to edit its products and click 'Save' button, my save works only until my app gets terminated. The problem is only with my products array - the rest (e.g. payment

CoreData: Fetching an Object from an unsaved Context

跟風遠走 提交于 2019-12-03 15:04:35
after I insert a ManagedObject into a context I'd like to fetch it later but before saving the context (I'd save after all objects are inserted). It appears that querying the context later with a fetch concerning those objects returns nothing if the context wasn't previously saved. Is there a way to save only in the end ?(I guess i can save my objects in an array or dictionary and query that but i thought coredata would do this for me) Try this: [myFetchRequest setIncludesPendingChanges:YES]; From the documentation : Sets if, when the fetch is executed, it matches against currently unsaved

Can't instantiate subclass of NSManagedObject

谁都会走 提交于 2019-12-03 14:20:04
Xcode 6 has had a ton of bugs. But I'm not quite sure if this is a bug or not. It might not be since this is something I'm just now learning. My issue is, any time I try to instantiate my subclass of NSManagedObject, I do not have the option to pass the entity: NSEntityDescription and NSManagedContext: insertIntoManagedContext argument to the constructor, Xcode says "Extra Argument 'entity' in call" I created a new Xcode project from scratch, just to see if I could re-create the problem in a smaller, minimal project. ToDoList.Item is set as the Item entity class in the Data Model Inspector.

Crash with NSManagedObject release: “objc_msgSend() selector name: _queueForDealloc”

放肆的年华 提交于 2019-12-03 13:34:08
I have been getting a strange crash reported by lots of users through HockeyApp with the following stack trace. It seems to have something to do with NSManagedObject being released in a different dispatch queue ... but I don't get any symbolication for where the problem might be. It seems like a memory management issue, but I'm using ARC so not sure how it would over-release an NSManagedObject. This is the crash report I get (the main thread shows different traces at different times): Code Type: ARM-64 Parent Process: launchd [1] Date/Time: 2014-05-12T05:43:54Z OS Version: iPhone OS 7.0.6