core-data

NSManagedObjectContext save doesn't crash but breaks on objc_exception_throw

时光怂恿深爱的人放手 提交于 2020-01-11 02:38:27
问题 I am having the same issue described at this address http://www.cocoabuilder.com/archive/cocoa/288659-iphone-nsmanagedobjectcontext-save-doesn-crash-but-breaks-on-objc-exception-throw.html I am debugging an application that uses Core Data with multithreading, and I have a breakpoint on objc_exception_throw and it hits this breakpoint in the call to save. (line 2 in code) NSError *error = nil; [self.managedObjectContext save:&error]; if (error) { NSLog(@"Error : %@",error); } I don't have any

NSManagedObjectContext save doesn't crash but breaks on objc_exception_throw

爱⌒轻易说出口 提交于 2020-01-11 02:37:32
问题 I am having the same issue described at this address http://www.cocoabuilder.com/archive/cocoa/288659-iphone-nsmanagedobjectcontext-save-doesn-crash-but-breaks-on-objc-exception-throw.html I am debugging an application that uses Core Data with multithreading, and I have a breakpoint on objc_exception_throw and it hits this breakpoint in the call to save. (line 2 in code) NSError *error = nil; [self.managedObjectContext save:&error]; if (error) { NSLog(@"Error : %@",error); } I don't have any

Sorting NSFetchedResultsController by Swift Computed Property on NSManagedObjectSubclass

人走茶凉 提交于 2020-01-11 02:04:54
问题 I'm building an app using Swift with Core Data. At one point in my app, I want to have a UITableView show all the objects of a type currently in the Persistent Store. Currently, I'm retrieving them and showing them in the table view using an NSFetchedResultsController . I want the table view to be sorted by a computed property of my NSManagedObject subclass, which looks like this: class MHClub: NSManagedObject{ @NSManaged var name: String @NSManaged var shots: NSSet var averageDistance: Int{

Core Data Relationship Fault

帅比萌擦擦* 提交于 2020-01-10 23:25:00
问题 Tracking a familial relationship in Core Data (1 parent entity + 2 types of children, one of which is recursive), trying to create a drop-menu in Interface Builder that lists the names of the parent entities so that the user can choose one to associate as the parent of the entry being edited. I've got the bindings all set, but when it runs it produces the following error text in the first slot of the menu: Relationship fault for ( <NSRelationshipDescription: 0x100143ed0> ), name parent,

How to automatically delete oldest core data entries when reach 50 entry limit?

六眼飞鱼酱① 提交于 2020-01-10 19:44:11
问题 What I'm trying to accomplish is the following: I need to limit the amount of core data entries to 50. So if the user enters their 50th entry then the app would delete the oldest entry and add the new entry to the top of the stack. So basically, if the user never deletes entries and if there are 50 entries in core data then, when the user tries to add a new entry, the app would delete the oldest entry and add the user's new entry. Basically, I'm trying to have a history sort of thing but I

Core data: Failed to load model

僤鯓⒐⒋嵵緔 提交于 2020-01-10 09:22:59
问题 I am new to core data. What I am trying to DO: I am trying to create a cocoatouch framework that has an app to add employee details and display them in a table view. So that i can add this framework to my main project to work independently. Issues I face: The frame work builds without any error. I have added the core data stack from swift 3 to the framework. But when i run the main project, the moment the framework loads the log displays "Failed to load model named Simple framework", "fetch

Background saving with Core Data?

一曲冷凌霜 提交于 2020-01-10 08:26:11
问题 I have a Core Data based iPhone application that needs to save 1000 managed objects on termination. This takes 8+ seconds, however, the OS kills the app if it does not complete in approx. 6 seconds. I don't want to save the objects earlier, because then the user has to wait 8 seconds longer for the results to display. Is it possible to somehow save the objects earlier in a background thread, while still having (read-only) access to the NSManagedObjectContext in the main thread to display the

Backup core data locally, and restore from backup - Swift

孤街醉人 提交于 2020-01-10 06:49:07
问题 I'm struggling to find any information about creating backups of core data. My ultimate goal is to allow the user to create multiple backups, and restore from a selected backup. I've found a sample project that allows you backup/restore locally or via iCloud in Objective-C, but nothing in swift. Can anyone help? Or point me in the right direction. I don't even know where to start with this one. 回答1: I've never needed to do this but if I did this is what I'd do. To make backups At any time,

Core Data migration fails for to-one relationship

旧街凉风 提交于 2020-01-10 05:37:25
问题 I have the following model: parent is a to-one relationship (optional, no minimum, maximum=1). children is the inverse to-many relationship (optional, no minimum, no maximum). I added a new model version, where only the Entity Room is renamed to Classroom , all other entities are unchanged: I also created a mapping model for the migration, but the migration fails with the error message reason = "Can't find mapping model for migration"; The strange thing is that if the parent relationship is

iPhone CoreData join

我是研究僧i 提交于 2020-01-10 03:18:09
问题 this is my core data model: I'm trying to get all LanguageEntries from a database for a given category.categoryName and languageset.languageSetName e.g. NSFetchRequest* fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"LanguageEntry" inManagedObjectContext:del.managedObjectContext]; [fetchRequest setEntity:entity]; NSString* predicateString = [NSString stringWithFormat:@"Category.categoryName = %@ AND LanguageSet.languageSetName =