ios - How do I retrieve additional properties for entity matching "max:" expression -
i have fetchrequest returns max value correctly particular key path. set looks this:
nsexpression *keyexpression = [nsexpression expressionforkeypath:@"distance"]; nsexpression *functionexpression = [nsexpression expressionforfunction:@"max:" arguments:@[keyexpression]]; nsexpressiondescription *expressiondescription = [[nsexpressiondescription alloc] init]; [expressiondescription setname:keypath]; [expressiondescription setexpression:functionexpression]; [expressiondescription setexpressionresulttype:nsinteger32attributetype];
the problem need return value property on object matching above nsexpressiondescription. in other words, want value of timestamp property returned managedobject max: value being returned. if set fetch request this:
nsfetchrequest* request = [nsfetchrequest fetchrequestwithentityname:@"record"]; request.resulttype = nsdictionaryresulttype; request.propertiestofetch = @[expressiondescription, @"timestamp"]; request.propertiestogroupby = @[@"timestamp"];
it returns dictionary each of records has timestamp instead of 1 dictionary record matching max value. idea how can result i'm after?
construct fetch request return items want (this dictionary or managed object). rather using max expression though set fetchlimit
1 , add sort descriptor result maximum value distance
returned (because first item in result set).
Comments
Post a Comment