Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. Employees<->>ClockPunches
  2.  
  3. NSFetchRequest* request = [Registration fetchRequest];
  4. NSExpression *date = [NSExpression expressionForKeyPath:@"time"];
  5.  
  6. NSExpression *maxDate = [NSExpression expressionForFunction:@"max:"
  7. arguments:[NSArray arrayWithObject:date]];
  8.  
  9. NSExpressionDescription *d = [[[NSExpressionDescription alloc] init] autorelease];
  10. [d setName:@"maxTime"];
  11. [d setExpression:maxDate];
  12. [d setExpressionResultType:NSDateAttributeType];
  13. [request setPropertiesToFetch:[NSArray arrayWithObject:d]];
  14.  
  15. NSError *error = nil;
  16. NSArray *objects = [Registration executeFetchRequest:request];
  17. if (objects == nil) {
  18. // Handle the error.
  19. } else {
  20. if (0 < [objects count]) {
  21. NSLog(@"Maximum date: %@", [[objects objectAtIndex:0] valueForKey:@"type"]);
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement