nsfetchrequest

fetching core data values using predicate

僤鯓⒐⒋嵵緔 提交于 2020-01-07 04:40:50
问题 my sqlite have items in one of the entity and i wish to retrieve them out according to their categoryID e.g. categoryID 1 have 7 items and categoryID 2 have 5 items , when i clicked on an IBAction it will come to this method and retrieve according to my global.clickedTag but i'm unable to retrieve the values , any idea why? -(NSMutableArray*)fetchItem:array{ [self managedObjectContext]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"IItem" inManagedObjectContext

Alternate way to retrieve data from core data database - ios

会有一股神秘感。 提交于 2020-01-07 03:49:54
问题 I am having performance issues while retrieving data from the database. Right now, this is how I do it. +(NSMutableArray *) searchObjectsInContext: (NSString*) entityName : (NSPredicate *) predicate : (NSString*) sortKey : (BOOL) sortAscending { i3EAppDelegate *appDelegate = (i3EAppDelegate *)[[UIApplication sharedApplication] delegate]; NSManagedObjectContext *context = [appDelegate managedObjectContext]; NSFetchRequest *request = [[NSFetchRequest alloc] init]; NSEntityDescription *entity =

fetchresultscontroller issue or managed object context?

假装没事ソ 提交于 2020-01-06 19:56:33
问题 Reference POST: Core Data - Basic Questions I am able to get the Managed object context from this piece of code. It bring me to another question. I have 2 VIEW CONTROLLERS and 1 NSObject Userlookup (VC) UserlookupSettings(VC) FetchProcessor (NSObject) In sequence, Userlookup vc loads first and has a button to load the Userlookupsettings VC + a textbox and UiButton. When the app is loaded and I hit the SETTINGS uibutton, things work fine... however, when i do the search (FetchProcessor) and

Accessing data attribute of NSManagedObject gives me memory issues

自作多情 提交于 2020-01-06 19:38:50
问题 I think I might be accessing this wrong, perhaps somebody could point me in the right direction. I have a Entry entity, which has a one-to-many relationship with the Media entity. The Media entity contains a data attribute called originalImage . The first 50 Entry entities that this iterates through do not have any media items in the set. After that, it slows down as it accesses the originalImage attribute and eventually runs out of memory and quits to the home screen, without any message

Fetching all data from an Entity and printing only displays the last record

北城余情 提交于 2020-01-06 08:39:50
问题 I'm trying to fetch all of the data from a particular Core Data Entity and place each record into a string. However the following code only prints the LAST record that it accesses. What am I doing wrong? NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Order" inManagedObjectContext:managedObjectContext]; [fetchRequest setEntity:entity]; NSArray *fetchedObjects = [managedObjectContext executeFetchRequest

iOS: Two Entities - Fetch, Merge, and Sort

会有一股神秘感。 提交于 2020-01-06 02:26:27
问题 I need to perform a fetch from two different entities, merge them, and then sort them based on a field that both entities have: 'lastModifiedDate'. lastModifiedDate is NSDate NSFetchRequest *fetchRequest1 = [[NSFetchRequest alloc] init]; NSFetchRequest *fetchRequest2 = [[NSFetchRequest alloc] init]; NSEntityDescription *entity1 = [NSEntityDescription entityForName:@"Entity1" inManagedObjectContext:self.managedObjectContext]; [fetchRequest1 setEntity:entity1]; NSEntityDescription *entity2 =

Complex sorting for core-data fetch request

天涯浪子 提交于 2020-01-04 02:35:07
问题 I have an NSEntity ( Cloth ) with an attribute ( type ) which is filled from a list of predefined NSString values i.e. Poncho‎, Jacket, Coat, Gown, Top, Suit, etc. I want to fetch all the Cloth records such that the records are ordered based on a defined order for type . i.e. All the records for Poncho‎ are on top, then Jacket, then Coat, then Gown, then Top, then Suit, etc. Poncho‎ … Poncho‎ … Poncho‎ … Jacket … Jacket … Coat … Coat … Coat … Gown … Gown … Top … Top … Top … Top … Suit … Suit

Core Data NSPredicate filter by entity class?

梦想与她 提交于 2020-01-03 09:12:11
问题 How would I create an NSPredicate to filter by entity of class Contact ? The solution to NSPredicate check for kind of object class crashes: [NSPredicate predicateWithFormat:@"person.class == %@", [Contact class]]; *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'keypath person.class not found in entity <NSSQLEntity User id=12>' Background I have the Core Data entities User (app user) & Contact (address book contact), both children of Person (abstract

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

NSFetchRequest returning nothing

瘦欲@ 提交于 2020-01-02 07:26:09
问题 Can anyone spot why this isn't returning any ManagedObjects? I'm trying to add to the ATNSManagedObject+EasyFetching class the following, but the fetch result returns nothing. If I fetch these outside of the EasyFetch class I have 100+ objects so I know it isn't CoreData being empty. + (void)deleteAllObjectsInContext; { NSManagedObjectContext *context = [NSManagedObjectContext defaultContext]; NSEntityDescription *entity = [self entityDescriptionInContext:context]; NSFetchRequest *request = [