nsfetchedresultscontroller

NSFetchedResultsController seems to be inserting empty objects into array?

泄露秘密 提交于 2019-12-12 03:49:22
问题 I'm not sure what's going wrong. I have one Entity in my data model, called Quote, and around 3,000 of them stored in a .sqlite. I'm just trying to get one of the attributes of those entities into the cells of a UITableView , by way of an NSFetchedResultsController . The error I'm getting is on this line of code: NSFetchedResultsController *theFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest: fetchRequest managedObjectContext: [self managedObjectContext]

NSFetchedResultsController notifies its Delegate of delete changes when a managed object is modified, and never notifies for Insert or Update

我只是一个虾纸丫 提交于 2019-12-12 03:29:26
问题 I have a UITableViewController , which is a delegate for an NSFetchedResultsController . My NSFetchedResultsControllerDelegate functions are set up as per "Typical Use" in Apple's documentation, with the table view controller as the fetched result controller's delegate property. I also have some view controllers which are presented on top of the table view where the managed objects can be modified. These modifications are done on the same managed object context. There is only one managed

how to sort array from fetch by valueForKey

谁说胖子不能爱 提交于 2019-12-12 02:46:22
问题 I have a fetchResultController that compiles an array by running through multiple methods. The final cells display a name and number (ranking). I'd like to take the cells from the tableview and sort them by the number (ascending). I've tried nssortdescriptor in the frc but run into issues when I try to call the 'ranking' because it isn't a keypath of the entity I'm fetching. Is there a place I can intercept this array that comes out of the frc to sort by valueForKey:@"ranking"? How would I

Core data: How to display results of a fetchrequest for calculating values in a tableview cell

扶醉桌前 提交于 2019-12-12 02:43:16
问题 I am relatively new to iOS (I apologize beforehand if I am not clear or if the problem has been addressed elsewhere) and I have gone through a lot of tutorials to learn the basics. Still, I have been facing issues with doing the following with core data: I understand how to fetch data from DB with core data, sort it and display it, but now I don't know how to programatically work an attribute (it's a transient attribute in a table in my DB) that needs to be computed and displayed in a static

How do I change NSFetchResultController array that holds my objects to different indexes for my objects?

旧街凉风 提交于 2019-12-12 01:49:43
问题 I have a method that I use to hold and move cells in my table view to different index that looks like this: - (void)moveTableView:(FMMoveTableView *)tableView moveRowFromIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { NSArray *allObjects = [self.fetchedResultController fetchedObjects]; //array to hold the new order NSMutableArray * arrayCorectOrder = [NSMutableArray new]; //the target object that is in the index we are moving from Target *target = [self

Is there any way to be notified when sqlite tables update?

不羁的心 提交于 2019-12-12 01:38:41
问题 I am developing an iOS app that uses sqlite database with the help of FMDB . I used to work with Core Data , but it was very slow with 5000 items insert at a time. FMDB with transactions make such inserts much more faster! Also I need some mechanism that can notify my view controllers when some items from sqlite table are updated. NSFetchedResultsController was my solution, but since I use FMDB I can no longer use NSFetchedResultsController . Is there any way to be notified when sqlite tables

Create Array From Attribute of NSObject From NSFetchResultsController

心不动则不痛 提交于 2019-12-12 01:26:43
问题 I have a NSFetchResultsController that fetches a NSObject. NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"WeekDay" inManagedObjectContext:self.managedObjectContext]; [fetchRequest setEntity:entity]; [fetchRequest setPredicate: predicate]; NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"timeStamp" ascending:NO]; NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor,

What is causing the difference in this Core Data output?

二次信任 提交于 2019-12-12 00:55:39
问题 I am having difficulty with an NSFetchedResultsController which is returning 0 sections the first time I run my app but the correct number of sections when I close and reload the app subsequently. I have noticed that if I NSLog the array[[self.fetchedResultsController fetchedObjects] description], I get a slightly different result between the first and subsequent times, and I'm hoping this will help me figure out the overall problem. First Run: "<Contact: 0x1fc7a000> (entity: Contact; id:

UITableViewCell button tags return desired IndexPath in UISearchController, not FetchedResultsController

你离开我真会死。 提交于 2019-12-11 22:54:59
问题 I implemented an NSFetchedResultsController on a UITableView in a Core Data project in Swift 2.0. Additionally, I have a UISearchController implemented. Everything works perfectly with the exception of the behavior I'm encountering on my custom UITableViewCell buttons. When UISearchController is active, the customTableViewCell 's buttons work as they should. If I click the same button when the fetchedResultsController is displaying its results, the method thinks Index 0 is the sender,

NSPredicate for detecting Class of the property

江枫思渺然 提交于 2019-12-11 20:01:37
问题 I have events, each Event has to-one relationship with NSManagedObject Entertainment, and Entertainment has to-many relationship, and has NSSet of events @interface Event : NSManagedObject @property (nonatomic, retain) NSDate *creationDate; @property (nonatomic, retain) NSDate * date; @property (nonatomic, retain) NSString * objectId; @property (nonatomic, retain) NSString * price; @property (nonatomic, retain) Entertainment *entertainment; @property (nonatomic, retain) Place *place;