core-data

Can I save user's drafts using NSUserDefaults?

I am trying to save drafts using NSUserDefaults but I am not sure if it is the right place to save data not user's preferences in. My application allows user to choose 1 or 2 images to upload and share. Users can save draft and come back to upload later. My current approach is to save the chosen UIImage to /Library directory and save t...

How to maintain an ordered table with Core Data (or SQL) with insertions/deletions?

This question is in the context of Core Data, but if I am not mistaken, it applies equally well to a more general SQL case. I want to maintain an ordered table using Core Data, with the possibility for the user to: reorder rows insert new lines anywhere delete any existing line What's the best data model to do that? I can see two wa...

NSPredicate for an NSManagedObject's string attribute's length

Could someone please help me define a predicate that returns only NSManagedObject's who's "letters" attribute length is within a certain range? Here's the example I've been trying, I've got a feeling it's the letters.length notation, I've also tried the kvc letters.@length with no success.. What am I doing wrong? NSManagedObjectContext...

Core Data, try to use NSPredicate to filter a toMany relationship set but get the "to-many key not allowed here" error

Here is the model I have: http://www.girardet.ch/model.png My goal is to retrieve all the Quotes with these criterias: belong to a specific theme : the name_en attribute of Themes order by relevancy filtered by Authors (with the alias attribute of Authors) Here is my code: NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init...

unrecognized selector sent to instance

I added an index search to a core data backed UITableView. the search works fine, however after navigating back to the tableView I get this error: -[NSSQLRow controllerDidChangeContent:]: unrecognized selector sent to instance 0x815edf0 I can post more code if this is too little information to go on. thanks for any help ...

Having trouble copying data to a mutable array

I keep getting the error "Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[MainViewController minimalFormInContext:]: unrecognized selector sent to class" from this line of code: NSLog(@"Accessing specific mine entities"); NSEntityDescription *entity = [NSEntityDescription entityForName:@"Mine" inMa...

Core Data inverse relation does not get set

I have an object A with a to-many relation to B. B has a property A that is the inverse relation to A's NSSet. Pseudo code: class A{ NSSet *bConnections; } class B{ A *aConnection; } In the model I have set up the relationship as optional. For A, the relationship is defines as to-many, inverse of aConnection at B and delete...

NSEntityMigrationPolicy subclass methods not being called

I am trying to migrate from one .xcdatamodel file to another. I have a NSEntityMigrationPolicy subclass, the name of which I have entered in xcode-> .xcmappingmodel file -> entity -> "custom Policy" field. I run my app which successfully opens and runs the previous version of my data so I can only assume basic migration has worked. HOWE...

ZSync tutorial - Syncing CoreData data between devices

I am interested in syncing CoreData data amongst several apps running on iPhone, iPad and MacOSX. I found ZSync project from Mr Zarra but did not find any related tutorial. I contacted Mr Zarra who is always working on improving ZSync (thanks for that) and do not have planned yet to write a tutorial. Any of you have implemented ZSync fu...

CoreData: Is it possible to merge .xcdatamodel "files"?

I know .xcdatamodel is actually a directory with two files (elements and layout). I know the two files are binary plists, and can convert them to XML plists with plutil -convert xml1 (while relying on this may be "unwise", it's perfectly fine for development: I expect that the build tools will compile/optimise/whatever when putting them...

In Core Data, can I make a parent property optional in only one of the children?

In core data, in the xcdatamodel file, if i want to specify a parent object, but for one of the children of the parent object, i want a property to be optional, and for the other, i don't want to check optional, is there a way to do that? or should i just take the property out of the parent and put it in the children so that I can make o...

iPhone: NSSet keep sort order

I have an NSMutableArray which has about 18 objects. They are in a specific order that I want. I have to add these objects into an NSSet to be saved in Core Data. But, once I pull them out of the NSSet using [myObject.items allObjects] it does not keep the original order that I added the objects as. How can I keep the order that I ...

How would you model Location in Core Data?

I want to make an Entity for Location with properties: latitude & longitude. Then, I want to set a relationship from User to Location, from Photo to Location, etc. Should I do it without creating an inverse relationship from Location to the others? Otherwise, how would I do it like that? Thanks! Matt ...

CoreData can't find mapping model in an OSX framework bundle, but works fine in iOS

I have CoreData-based data layer (using a SQLite datastore) that I am using in both an iOS app and on the server that the iOS clients talk to. The data layer (objc code + coredata model / mapping defns) is compiled into the iOS bundle as per usual, and is compiled into a Framework bundle for use on OSX. I am hitting a brick wall with d...

CoreData: NSManagedObject extensions

Hello, I'm using CoreData and I have two managed objects: Author and Book. An author can have may books, but a book can only have one author (for the sake of this example). The class Author extends NSManagedObject and Book extends NSManagedObject also. In my Author class, is it OK to create an extension, so that I can do custom searche...

Core Data database doesn't save

I'm trying to implement the Paparazzi 2 assignment from the Stanford CS193 course and I'm running into a problem. My one call to save the database is when the app exits (I'm borrowing heavily from Mike Postel's version to check my code): - (void)applicationWillTerminate:(UIApplication *)application { if (flickrContext != nil) { ...

NSPredicate that references multiple fields on a to-many relationship?

I'm using a SQLite persistent store. I have a NSManagedObject class Den with a to-many relationship Bear. Bear has several fields: Bear: breed color age ... When I am building fetch requests for my Foo objects, I can filter to objects that have a related Bear with a certain field value: NSPredicate *hasGrizzlyPred =...

iphone: use Entity object created from Core Data?

I currently have a Video object created via Core Data defined as: Video .h #import <CoreData/CoreData.h> @interface Video : NSManagedObject { } @property (nonatomic, retain) NSString * title; @property (nonatomic, retain) NSString * urlImage; @property (nonatomic, retain) NSString * description; @property (nonatomic, retain) NSS...

how to remove datamodel from core data and add a new one?

Hi, I am working on a iphone application project. we have released one application with a coredata model, now in our new release we like to remove the old one and add a new one. (we are not storing any user values on existing core data model). we forgot to remove the xcdatamodel from our application folder, but we removed all code relat...

Need help fast -- CoreData error

Hello, need help desperately ahead of a demo in a few hours... App was working on my test device fine last night. Added some data (as I always do) this morning and now I get this error during a save operation: Serious application error. Exception was caught during Core Data change processing: *** -[NSCFDictionary setObjec...