Skip to content

Commit 95dafc8

Browse files
committed
Use type-safe keypath constructor in PFQueryState.
1 parent 1afc84c commit 95dafc8

File tree

3 files changed

+35
-22
lines changed

3 files changed

+35
-22
lines changed

Parse/Internal/Query/State/PFMutableQueryState.m

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#import "PFQueryConstants.h"
1212

1313
#import "PFQueryState_Private.h"
14+
#import "PFMacros.h"
1415

1516
@interface PFMutableQueryState () {
1617
NSMutableDictionary<NSString *, id> *_conditions;
@@ -47,10 +48,10 @@ @implementation PFMutableQueryState
4748
+ (NSDictionary *)propertyAttributes {
4849
NSMutableDictionary *attributes = [[super propertyAttributes] mutableCopy];
4950

50-
attributes[@"conditions"] = [PFPropertyAttributes attributesWithAssociationType:PFPropertyInfoAssociationTypeMutableCopy];
51-
attributes[@"sortKeys"] = [PFPropertyAttributes attributesWithAssociationType:PFPropertyInfoAssociationTypeMutableCopy];
52-
attributes[@"includedKeys"] = [PFPropertyAttributes attributesWithAssociationType:PFPropertyInfoAssociationTypeMutableCopy];
53-
attributes[@"extraOptions"] = [PFPropertyAttributes attributesWithAssociationType:PFPropertyInfoAssociationTypeMutableCopy];
51+
attributes[PFQueryStatePropertyName(conditions)] = [PFPropertyAttributes attributesWithAssociationType:PFPropertyInfoAssociationTypeMutableCopy];
52+
attributes[PFQueryStatePropertyName(sortKeys)] = [PFPropertyAttributes attributesWithAssociationType:PFPropertyInfoAssociationTypeMutableCopy];
53+
attributes[PFQueryStatePropertyName(includedKeys)] = [PFPropertyAttributes attributesWithAssociationType:PFPropertyInfoAssociationTypeMutableCopy];
54+
attributes[PFQueryStatePropertyName(extraOptions)] = [PFPropertyAttributes attributesWithAssociationType:PFPropertyInfoAssociationTypeMutableCopy];
5455

5556
return attributes;
5657
}

Parse/Internal/Query/State/PFQueryState.m

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#import "PFMutableQueryState.h"
1414
#import "PFPropertyInfo.h"
15+
#import "PFMacros.h"
1516

1617
@implementation PFQueryState
1718

@@ -21,24 +22,24 @@ @implementation PFQueryState
2122

2223
+ (NSDictionary *)propertyAttributes {
2324
return @{
24-
@"parseClassName": [PFPropertyAttributes attributesWithAssociationType:PFPropertyInfoAssociationTypeCopy],
25-
@"conditions": [PFPropertyAttributes attributesWithAssociationType:PFPropertyInfoAssociationTypeCopy],
26-
@"sortKeys": [PFPropertyAttributes attributesWithAssociationType:PFPropertyInfoAssociationTypeCopy],
27-
@"includedKeys": [PFPropertyAttributes attributesWithAssociationType:PFPropertyInfoAssociationTypeCopy],
28-
@"selectedKeys": [PFPropertyAttributes attributesWithAssociationType:PFPropertyInfoAssociationTypeCopy],
29-
@"extraOptions": [PFPropertyAttributes attributesWithAssociationType:PFPropertyInfoAssociationTypeCopy],
30-
31-
@"limit": [PFPropertyAttributes attributes],
32-
@"skip": [PFPropertyAttributes attributes],
33-
@"cachePolicy": [PFPropertyAttributes attributes],
34-
@"maxCacheAge": [PFPropertyAttributes attributes],
35-
36-
@"trace": [PFPropertyAttributes attributes],
37-
@"shouldIgnoreACLs": [PFPropertyAttributes attributes],
38-
@"shouldIncludeDeletingEventually": [PFPropertyAttributes attributes],
39-
@"queriesLocalDatastore": [PFPropertyAttributes attributes],
40-
41-
@"localDatastorePinName": [PFPropertyAttributes attributesWithAssociationType:PFPropertyInfoAssociationTypeCopy]
25+
PFQueryStatePropertyName(parseClassName): [PFPropertyAttributes attributesWithAssociationType:PFPropertyInfoAssociationTypeCopy],
26+
PFQueryStatePropertyName(conditions): [PFPropertyAttributes attributesWithAssociationType:PFPropertyInfoAssociationTypeCopy],
27+
PFQueryStatePropertyName(sortKeys): [PFPropertyAttributes attributesWithAssociationType:PFPropertyInfoAssociationTypeCopy],
28+
PFQueryStatePropertyName(includedKeys): [PFPropertyAttributes attributesWithAssociationType:PFPropertyInfoAssociationTypeCopy],
29+
PFQueryStatePropertyName(selectedKeys): [PFPropertyAttributes attributesWithAssociationType:PFPropertyInfoAssociationTypeCopy],
30+
PFQueryStatePropertyName(extraOptions): [PFPropertyAttributes attributesWithAssociationType:PFPropertyInfoAssociationTypeCopy],
31+
32+
PFQueryStatePropertyName(limit): [PFPropertyAttributes attributes],
33+
PFQueryStatePropertyName(skip): [PFPropertyAttributes attributes],
34+
PFQueryStatePropertyName(cachePolicy): [PFPropertyAttributes attributes],
35+
PFQueryStatePropertyName(maxCacheAge): [PFPropertyAttributes attributes],
36+
37+
PFQueryStatePropertyName(trace): [PFPropertyAttributes attributes],
38+
PFQueryStatePropertyName(shouldIgnoreACLs): [PFPropertyAttributes attributes],
39+
PFQueryStatePropertyName(shouldIncludeDeletingEventually): [PFPropertyAttributes attributes],
40+
PFQueryStatePropertyName(queriesLocalDatastore): [PFPropertyAttributes attributes],
41+
42+
PFQueryStatePropertyName(localDatastorePinName): [PFPropertyAttributes attributesWithAssociationType:PFPropertyInfoAssociationTypeCopy]
4243
};
4344
}
4445

Parse/Internal/Query/State/PFQueryState_Private.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@
99

1010
#import "PFQueryState.h"
1111

12+
#import "PFMacros.h"
13+
14+
/**
15+
Returns NSString representation of a property on PFQueryState.
16+
17+
@param NAME The name of the property.
18+
19+
@return NSString representaiton of a given property.
20+
*/
21+
#define PFQueryStatePropertyName(NAME) @keypath(PFQueryState, NAME)
22+
1223
@interface PFQueryState () {
1324
@protected
1425
NSString *_parseClassName;

0 commit comments

Comments
 (0)