Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select sum(amount), date from db.table group by date;
- // Retrieve the entity from the local store -- much like a table in a database
- NSEntityDescription *entity = [NSEntityDescription entityForName:@"AppSettings" inManagedObjectContext:managedObjectContext];
- NSFetchRequest *request = [[NSFetchRequest alloc] init];
- [request setEntity:entity];
- // Set the predicate -- much like a WHERE statement in a SQL database
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"version == %@", @"Default"];
- [request setPredicate:predicate];
- // Set the sorting -- mandatory, even if you're fetching a single record/object
- NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"version" ascending:YES];
- NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];
- [request setSortDescriptors:sortDescriptors];
- sortDescriptors = nil;
- sortDescriptor = nil;
- // Request the data -- NOTE, this assumes only one match, that
- // yourIdentifyingQualifier is unique. It just grabs the first object in the array.
- AppSettings *appSettings1 =[[managedObjectContext executeFetchRequest:request error:&error] objectAtIndex:0];
- request = nil;
- //Update the object
- appSettings1.backGroundImage = [NSNumber numberWithInt: backGroundGraphics.selectedSegmentIndex];
Add Comment
Please, Sign In to add comment