core-data

Core Data, how can you avoid inserting dupicate recrods?

I have a web service call that returns XML which I convert into domain objects, I then want to insert these domain objects into my Core Data store. However, I really want to make sure that I dont insert duplicates (the objects have a date stamp which makes them unique which I would hope to use for the uniqueness check). I really dont w...

NSTableView and data validation?

In order to properly learn Objective-C and the Cocoa framework, I have started building a CoreData application, but I'm a bit at a loss on how to properly provide data validation when an item is being edited in an NSTableView. My model has an entity called "Business" with two string properties: a name and an issued tax number. The secon...

Problem deleting objects from Core Data - crashing app

Hello, My app is crashing when testing on the device, but not on the simulator. It happens when I go to log out. I'm deleting all records from core data when the user logs out, code as follows: -(IBAction)logOut { UIAlertView *getConfirmation = [[UIAlertView alloc] initWithTitle:@"Confirm" message:@"Are you sure you want to logout...

optional parameters

I have taken (with the authors permission on the site) a wrapper class for writing fetch requests to my Core Data stack. The guy who wrote it says it has "optional parameters" and I wondered what this meant. Anywho, the static methods are written as such... +(NSMutableArray *) searchObjectsFromContext : (NSString*) entityName ...

How do I create the right NSPredicate for this kind of request?

Hi the problem goes like this: I have in CoreData entities that have a title and a relationship to keywords entities. I need a predicate that helps me to fetch all those entities whose title contains the keywords I type. I have the code below that should do this but it doesn't: NSArray *keywords = [searchString componentsSeparatedByS...

Crashing on saving a managedObjectContext, with 'NSInvalidArgumentException', but only sporadically

I keep getting crashes from a save: command on a managedObjectContext. It doesn't even fulfill the NSLog statement so I don't see the unresolved error statement, so I can't figure out what the problem might be. It doesn't happen every time, but only sporadically. Here's the code (which basically wants to increment a counter): if ([[...

Core Data app crashing with "controllerWillChangeContent : unrecognized selector sent to instance"

Hi. I've got a core data app with 2 views. The first view lists "Rooms", the second lists "Scenes" in rooms. The Rooms page has an edit NavItem button, which when pressed enables an add NavItem button. You can delete and add rooms from here. Added rooms simply appear with a default "New Room" name in the table. The second view is a list ...

xCode Sqlite Database Creation Without Z_METADATA

When my sqlite database is created using a core data model, at this line: if (![persistentStoreCoordinator_ addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:options error:&error]) I get an error: NSUnderlyingException=I/O SQLite error code:1, 'no such table: Z_METADATA' Any idea ...

Best Persistence model for iPhone development

I'm finishing my second book on iPhone development (Beginning Iphone 3 Development - Mark/LaMarche) and, while this book covers the 4 main persistence mechanisms, I'm still not sure which one to use for my application. My data model is not very intricate, but I do need some relationship definition and functionality. So what are the sea...

How do I achieve the effect of two to-many relationships to the same entity from one entity?

I am having a hard time wrapping my head around data models. Let me start with showing how I would declare the class if I just had to have in-memory objects. @interface PlayerState { NSSet /* of SavedDie */ *savedDice; NSSet /* of SavedDie */ *immediateRolls; } @property (nonatomic, retain) NSSet *savedDice; @property (nonatomic,...

Problem binding an NSArrayController back to an ivar

Hi everybody, I have a problem with a bound property of a custom view. The property is bound to an NSArrayController for a core-data entity. Here's the problem: In my view, I draw several rectangles. The positions of these rectangles are saved in an entity in core data (as NSValue wrapped NSRects). The rectangles are draggable, and wh...

How to detect object is cascade deleted by coredata

I have two entities: Folder <-->> Document, and Folder defines a To-Many relationship to Document with a cascade delete rule. My question is: is there some way for document object itself to detect when it is cascade deleted ? ...

iPhone Core Data get Grandchildren

If I have entities set up for Parent - Child - Grandchild and one to many relations between them I know I can then get all the Child entities for a parent or all the Grandchild Entities for a Child. Is it possible to run a fetch that will get all the Granchild entities for a given Parent? Thanks for any help! ...

Deleting a CoreData object, then calling [tableView reloadData] causes a SIGABRT

Hi, I'm supporting deleting rows in a UIView that includes a tableView: - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { if (editingStyle == UITableViewCellEditingStyleDelete) { [self.fetchedResultsController.managedObjectContext ...

NSFetchRequest and predicateWithBlock

Hello, I am playing with an app that uses Core Data and NSManagedObjects to populate a UITableView. There is only one class in my application, called Event. I have created the following custom instance method on Event: - (BOOL)isExpired { return ([[self.endOn dateAtEndOfDay] timeIntervalSinceNow] < 0); } I would like to limit t...

adding a new sqlite field problem...

I've added a new field to an SQLite db table and have also added a new attribute in core data xcdatamodel. I made sure to delete the app from the iphone simulator. the app runs fine, but isn't finding the new field. if i change the data on an existing field in SQLite and relaunch the app, the change is there. the new field is not. anyo...

Iphone - Video Recording Applications - Use Camera Roll or store in app / database?

For those of you making iphone applications that record video Are you utilising the camera roll for storage and then indexing the asset URL? Or are you somehow saving the video to the app / bundle / database? Does the stackoverflow community think it is viable to just store the asset url for replaying or that one should somehow store...

About entity transient attribute in core data

I have an entity with an transient attribute, and it's optional flag is set to NO. If I fetch an instance of this entity from persistent store, change something and save back, need I set this transient attribute ? ...

Core Data, NSTableView and getting Selected Row Value

I'm pretty new to Core Data and managed to get the NSTableView to show my Core Data values. The entity that the table uses is Emotes that have the two properties, Emote (string) and Usage (integer 16) When a user selects a item, it will allow a person to copy that emote to clipboard. In order to do that, I need to get the ManagedObject ...

core data adding a new field to an existing sqlite table

I have an sqlite table that I'd like to add a new field to. Would I add the new field directly in sqlite or does the Core Data model change the sqlite table itself? I'm stuck for some reason right now w/ adding a new field to the db table. thanks for any help. ...