Guest User

Untitled

a guest
Jan 19th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. select sum(amount), date from db.table group by date;
  2.  
  3. // Retrieve the entity from the local store -- much like a table in a database
  4. NSEntityDescription *entity = [NSEntityDescription entityForName:@"AppSettings" inManagedObjectContext:managedObjectContext];
  5. NSFetchRequest *request = [[NSFetchRequest alloc] init];
  6. [request setEntity:entity];
  7.  
  8.  
  9. // Set the predicate -- much like a WHERE statement in a SQL database
  10. NSPredicate *predicate = [NSPredicate predicateWithFormat:@"version == %@", @"Default"];
  11. [request setPredicate:predicate];
  12.  
  13.  
  14. // Set the sorting -- mandatory, even if you're fetching a single record/object
  15.  
  16. NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"version" ascending:YES];
  17. NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];
  18. [request setSortDescriptors:sortDescriptors];
  19. sortDescriptors = nil;
  20. sortDescriptor = nil;
  21.  
  22. // Request the data -- NOTE, this assumes only one match, that
  23. // yourIdentifyingQualifier is unique. It just grabs the first object in the array.
  24. AppSettings *appSettings1 =[[managedObjectContext executeFetchRequest:request error:&error] objectAtIndex:0];
  25.  
  26. request = nil;
  27.  
  28.  
  29. //Update the object
  30. appSettings1.backGroundImage = [NSNumber numberWithInt: backGroundGraphics.selectedSegmentIndex];
Add Comment
Please, Sign In to add comment