core-data

Which it is the place for NSFetchedResultsController in VIPER architecture?

☆樱花仙子☆ 提交于 2020-01-03 09:11:53
问题 In VIPER, unlike the MVC, the role and place not so clearly defined for NSFetchedResultsController. Is it right to place it on the interactor? 回答1: According to this article interactor should not know how to persist the entities. VIPER and the architecture that uses NSFetchResultController are different approaches. There is no right place for NSFetchResultController in VIPER. VIPER is good for big application as it provides architecture layers that are isolated well. NSFetchResultController

Which it is the place for NSFetchedResultsController in VIPER architecture?

◇◆丶佛笑我妖孽 提交于 2020-01-03 09:11:46
问题 In VIPER, unlike the MVC, the role and place not so clearly defined for NSFetchedResultsController. Is it right to place it on the interactor? 回答1: According to this article interactor should not know how to persist the entities. VIPER and the architecture that uses NSFetchResultController are different approaches. There is no right place for NSFetchResultController in VIPER. VIPER is good for big application as it provides architecture layers that are isolated well. NSFetchResultController

Core Data: sorting by count in a to-many relationship

倖福魔咒の 提交于 2020-01-03 07:19:14
问题 I am currently trying to setup a NSFetchedResultsController that will order my table view based on the number of entities in a to-many relationship. I am not sure if this makes a difference when counting, but this is also an inverse relationship. I thought something like this would work just fine: NSEntityDescription *entity = [NSEntityDescription entityForName:@"Parent" inManagedObjectContext:managedObjectContext]; NSSortDescriptor *sortDescriptor1 = [[NSSortDescriptor alloc] initWithKey:@

Shared CoreData between apps

夙愿已清 提交于 2020-01-03 06:19:32
问题 My question somewhat similar to How to have multiple apps - one Core Data?. But I am not unable to replicate as suggested in the answer. I have two applications. One applications (1st App) allows user to do all sort of things and save in coredata. Other application (2nd App) is a service application. Here I want the service to get notified everytime the coredata is updated(any changes like create, delete, update done). If I use following notification in 2nd App, this notification does not get

Add “Add New” button in the last cell of UICollectionCell. (CoreData)

喜夏-厌秋 提交于 2020-01-03 05:20:53
问题 Trying to tackle this issue from different way. Current implementation gives me an error: 'NSInvalidArgumentException', reason: 'no object at index 3 in section at index 0' It occurs at class AppDelegate: UIResponder... My code is func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath) as! CollectionCell configureCell(cell: cell, indexPath:

Core data - how to get records from an entity and add them to another entity

谁说胖子不能爱 提交于 2020-01-03 05:18:06
问题 I have two entities: TempProducts and Products TempProducts is populated in TableView. The user must enter the data in the tableview.Than when he clicks on a button i need to get all records from TempProducts and add them to Products.After that i delete all TempProducts in order the table to be empty for next time. - (IBAction)saveData:(id)sender { //FETCH ALL RECORDS OF TEMPPRODUCTS NSFetchRequest * allTempProducts = [[NSFetchRequest alloc] init]; [allTempProducts setEntity:

Extremely Odd Crash When saving a transformable NSAttributedString into Core Data

偶尔善良 提交于 2020-01-03 05:15:30
问题 I have a project using Core Data. It has a Note object which has one transformable attribute called content. I am storing an NSAttributedString into this property. The property saves fine for the first save, but when I try to create a second note object, the app crashes. Here is the code I use to save: - (IBAction)save:(id)sender { Note* newNote = [NSEntityDescription insertNewObjectForEntityForName:@"Note" inManagedObjectContext:[self managedObjectContext]]; NSAttributedString* string = [

iPhone CoreData properties: changes to managedObjects are too slow

若如初见. 提交于 2020-01-03 05:11:23
问题 I have a CoreData model in my iPhone app, which is linked to a SQL Database with more than 50k records. When I generate the records classes, Xcode uses the @dynamic directive for properties. I have a property named "ISFAV", NSNumber type (CoreData does not use BOOL or Integer, it uses object types). Being short, I change the ISFAV property when the user taps on a button in this way: if (![record.ISFAV intValue]) record.ISFAV=[NSNumber numberWithInt:1]; else record.ISFAV=[NSNumber

Core data - Building a NSPredicate from a ManyToMany relationship

大憨熊 提交于 2020-01-03 04:50:14
问题 This is a follow up question to my previous question on: Core data: Managing employee contracts in a many-to-many relationship? There is a diagram on that question, and as a quick reminder there is the following: company --< contracts >-- employees I have been able to manually save 1 entity inside each of the entities, and verified them all in NSLog. I've created a CompanyListPage which lists all companies. The idea is that when you click on a company you will be presented with a list of all

Core Data Parent/Child context save fail

筅森魡賤 提交于 2020-01-03 04:43:07
问题 I setup a background thread with the Parent/Child model. Essentially the context save is failing. Here is my setup. In the AppDelegate i've setup the _managedObjectContext with the NSMainQueueConcurrencyType: - (NSManagedObjectContext *)managedObjectContext { if (_managedObjectContext != nil) { return _managedObjectContext; } NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator]; if (coordinator != nil) { _managedObjectContext = [[NSManagedObjectContext alloc]