Hi! can anyone guide me how to create a fetch request that will query an entity and returns any properties that qualify my criteria.
Here's what I have. I have an entity that has 35 properties, all are in types of float.
What I need was to see all properties of the entity which values was <= zero.
I know how to return the values of the...
Hello to everyone,
I cannot understanding why values assign to array objects become "disordered" after executing executeFetchRequest. Well, I'm not certain that fetching is the problem here. Here's the code.
objects=[NSArray arrayWithObjects:@"a",@"b",@"c",@"d",@"e",nil];
NSManagedObject *DB = nil;
for (int i=0;i<[objects count];i+...
Say I have a CoreData entity "Point" with two properties x and y (both NSNumber).
How would a NSPredicate need to look like to let me find the closest Point to say a,b?
for distance = sqrt((x-a)(x-a)+(y-b)(y-b))
While I could define a transient property that calculates a distance to a predefined point I can't see how I could programma...
Hi there,
I want the maximum value of a field in core data so I have set up the following request:
// Create fetch
NSFetchRequest *fetch = [[NSFetchRequest alloc] init];
[fetch setEntity:[NSEntityDescription entityForName:@"MyEntity" inManagedObjectContext:context]];
[fetch setResultType:NSDictionaryResultType];
// Expression for Max ...
Hi all,
I have a problem, and I reckon there's a really straightforward solution to it, but I can't fathom it out!
I have this piece of code:
NSManagedObjectContext * context = [[NSApp delegate] managedObjectContext];
NSManagedObjectModel * model = [[NSApp delegate] managedObjectModel];
NSDictionary * entities ...
I have a set of data where one of the attributes (Firmware) is a one-to-many relationship.
If I want to get any records where the firmware id is 1 I can create a predicate using
@"(ANY Firmware.FID==1)"
Then I have another set of conditions that will refine the set even more using
(TopLevel==YES) AND (Parent>0)
How can I combine t...
Hello
I am trying to create a Core Data iPhone application. One of the entities I'm tracking is cars, and one attribute of each car is "manufacturer".
In the "edit car" section of my application, I have a UIPickerView that needs to be loaded with each of the unique manufacturers that have previously been entered into the system. What...
Hi,
I have two managed objects which have a bidirectional relationship.
It is a 'segmentWithDetails' which contains a 'segment' object.
I use
NSEntityDescription *entity = [NSEntityDescription entityForName:@"SegmentWithDetails"
inManagedObjectContext:connectionDetailsService.connectionDetai...
I have some inefficiency in my app that I'd like to understand and fix.
My algorithm is:
fetch object collection from network
for each object:
if (corresponding locally stored object not found): -- A
create object
if (a nested related object locally not found): -- B
create a related object
I am doing the checking on l...
I'm trying to get sorted localized data from a core data model. My code:
NSEntityDescription *entityDescription = [NSEntityDescription entityForName: entityDescriptionValue
inManagedObjectContext: context];
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
[fetchRequest s...
For example, I have a Managed Object Model with an Entity called "Friends", and a friend has a firstName. I want to get all friends where the firstName is equal to "George". How can I do that?
...
Hi,
I am trying to perform a fetch on core data after i insert an entity, and I get 0 results.
I have a Person Entity.And i built a fetch Request in the DataModule GUI with the predicate:
name == "PERSONNAME"
Just before searching for the name i insert and save it first. and i know that works because i display the names in a table...
I have a question concerning Core Data and how, if at all, Entities get updated automatically.
Basically, let's say I fetch some data X. X has an inverse to-many relationship with Y. Then a method get's called to update an attribute in X. Does one have to fetch the data again? or will X automatically get the updated data?
If this is no...
I have my CD store setup and everything is working. Once my initial fetch is performed, I need to perform several fetches based on calculations using the data from my first fetch. The examples provided from Apple are great, and helped me get everything going but I'm struggling with executing successive fetches. Any suggestions, or tutori...
Hi,
I can't figure out why this is happening. I can add to the context. But when I retrieve the objects, it returns the correct number of objects but the attributes of the objects are null.
I am adding 3 instances with this code:
+(BOOL)addStoreWithID:(NSNumber *)ID Latitude:(NSNumber *)latitude Longitude:(NSNumber *)longitude Name:(N...
I have 2 entities, Task and List. Each task has a to-one relationship to a List object called "list", and there is an inverse relationship with List, which has a to-many relationship with Task called "tasks".
I'm trying to use a fetch request with an NSPredicate to get all the Task objects that belong to a specified List:
NSPredicate ...
In my iPhone Core Data app I have it configured in a master-detail view setup.
The master view is a UITableView that lists objects of the List entity. The List entity has a to-many relationship with the Task entity (called "tasks"), and the Task entity has an inverse to-one relationship with List called "list".
When a List object is se...
Hi,
I seem to recall that it's possible to return the resulting object count from an NSPredicate in CoreData without actually performing a fetch, but I can't find any reference to this.
Can someone confirm that I wasn't dreaming (sad dream to have!), and would this be safe to do in another thread?
Thanks
Andy
...
I have a case where i have three entities with one-to-many and one-to-many relationships:
Entity A (Entity B relationhip),
Entity B (Entity A relationship, Entity C relationship),
Entity C (Entity B relationhip)
I have the reference of Entity A, and now i want to fetch all the related Entity C records. How can i do that? (with least ...
In the following code:
- (NSMutableArray *) fetchNotesForGroup: (NSString *)groupName {
// Variables declaration
NSMutableArray *result;
NSFetchRequest *fetchRequest;
NSEntityDescription *entity;
NSSortDescriptor *sortDescriptor;
NSPredicate *searchPredicate;
NSError *error = nil;
// Creates the fetchRequest and executes it
f...