nsfetchrequest

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 relationship in my data model causes NSFetchRequest to return zero items

I have a simple entity called "Store" built in Xcode's data modeler for use in an iPhone application. I also have a class (Store) associated with it and I've been able to store and retrieve data using CoreData without any problems. Now I realized that I want to have a relationship to another entity (Aisle). There is already a one-to-o...

How do I use NSPredicate and a Fetch request to return an Array of entities where one Attribute contains a specific string?

I recently adapted my iPhone Application to use core data; after some research I have found that NSPredicate seems like the best way to handle my database queries. In particular, my queries will be based on 4 separate attributes. First, I need to query the database for all entities that have a specific county name. If I search for all en...

Having trouble copying data to a mutable array

I keep getting the error "Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[MainViewController minimalFormInContext:]: unrecognized selector sent to class" from this line of code: NSLog(@"Accessing specific mine entities"); NSEntityDescription *entity = [NSEntityDescription entityForName:@"Mine" inMa...

fetchresultscontroller issue or managed object context??

Reference POST: http://stackoverflow.com/questions/3681003/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 a...

Core Data: Fetch via specific property (join relationship)

I have an core data model as follows The attributes property of Page is a set of DictionaryEntry, they are values for my Page objects, much like a standard NSDictionary (except all of the keys and values are strings) I have a Page that has a DictionaryEntry with key="title" and value="Home". How would i form a fetch request to load t...

Why use NSFetchedResultsController?

Hi All, Core data provides the method "executeFetchRequest" in NSManagedObjectContext class, which we can use to fetch data from tables and use it whatever the way need to. Now there is another way by using NSFetchedResultsController and providing it to UITableView to fetch and data from tables. My questions are now: Which way is fa...

NSFetchedResultscontroller Callbacks not received in NSObject Class

Hi all, I have a class, @interface OnlineDataModel : TTModel < NSFetchedResultsControllerDelegate > { ... Where TTModel is, @interface TTModel : NSObject < TTModel > { ... OnlineDataModel class is Singleton, so its object never expires. I am performing the Fetch operation within this class and setting the delegate of the ...

Printing Core Data

I'm working on a program and I have created a fetch request to grab the data that I need to print. I'm able to log information like this: 2010-10-03 16:57:10.362 lzshow7.2[2537:10b] <NSManagedObject: 0x2ca120> (entity: Song; id: 0x2afcb0 <x-coredata://CF5A85CE-BE0F-4ADC-979A-7F4214A8FB19/Song/p9> ; data: { cueName = Freedom; cu...

Is it possible to sort by subclasses in an `NSFetchRequest` without adding additional attributes?

I want to group the results of a NSFetchRequest by entity. The entities all share the same abstract parent. For example: animal | |-cat | |-dog The NSFetchRequest has includesSubentities set TRUE and entity set to animal. It is possible to set sectionNameKeyPath of NSFetchedResultsController to entity.name but it is not possible to do...

Sorting a to-many relationship when calling NSFetchRequest

I have two entities. Client and Project. A Client has many Projects, but a Project can only be assigned to one Client. This has been designed with the datamodel. Client entity has attribute clientName and relationship to-many projects Project entity has attribute projectName and relationship to-one client I want to retrieve all Cli...

Core data, how to get NSArray of child object's ObjectIDs only?

I have a Core Data object, card, which has a child relationship relatedCards, which references other card objects. I am trying to get Core Data to give me an NSArray of the relatedCards' ObjectID values only—not the other property values for the cards. I know that one option is to run a fetch request such as: Card *myCard = <something> ...

Core data, how to get NSManagedObject's ObjectId when NSFetchRequest returns NSDictionaryResultType?

I have an NSFetchRequest which is returning the objects' properties in an NSDictionaryResultType. Is it possible to also get the objects' ObjectId within this dictionary? Otherwise I will need to run the query with a return type of NSManagedObjectResultType which is much slower for a large number of returned items. ...

Is it possible to have Core Data sort the "many" part of a To-Many relationship during a fetch request?

I'm using Core Data to cache a decent amount of information, and I have a To-Many relationship set up among my managed objects. Naturally I use an NSFetchRequest to fetch an array of the singular side of that relationship. However, I populate a UITableView using the the "many" side of the relationship, and I'd like it to be sorted alphab...