Skip to content

Commit a148058

Browse files
committed
Use type-safe keypath constructor in PFPushState.
1 parent 97ea9fc commit a148058

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

Parse/Internal/Push/State/PFPushState.m

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,38 +14,40 @@
1414
#import "PFQueryState.h"
1515
#import "PFAssert.h"
1616

17+
NS_ASSUME_NONNULL_BEGIN
18+
1719
@implementation PFPushState
1820

1921
///--------------------------------------
2022
#pragma mark - PFBaseStateSubclass
2123
///--------------------------------------
2224

2325
+ (NSDictionary *)propertyAttributes {
24-
return @{ @"channels": [PFPropertyAttributes attributesWithAssociationType:PFPropertyInfoAssociationTypeCopy],
25-
@"queryState": [PFPropertyAttributes attributesWithAssociationType:PFPropertyInfoAssociationTypeCopy],
26-
@"expirationDate": [PFPropertyAttributes attributesWithAssociationType:PFPropertyInfoAssociationTypeStrong],
27-
@"expirationTimeInterval": [PFPropertyAttributes attributesWithAssociationType:PFPropertyInfoAssociationTypeStrong],
28-
@"pushDate": [PFPropertyAttributes attributesWithAssociationType:PFPropertyInfoAssociationTypeStrong],
29-
@"payload": [PFPropertyAttributes attributesWithAssociationType:PFPropertyInfoAssociationTypeCopy] };
26+
return @{ PFPushStatePropertyName(channels): [PFPropertyAttributes attributesWithAssociationType:PFPropertyInfoAssociationTypeCopy],
27+
PFPushStatePropertyName(queryState): [PFPropertyAttributes attributesWithAssociationType:PFPropertyInfoAssociationTypeCopy],
28+
PFPushStatePropertyName(expirationDate): [PFPropertyAttributes attributesWithAssociationType:PFPropertyInfoAssociationTypeStrong],
29+
PFPushStatePropertyName(expirationTimeInterval): [PFPropertyAttributes attributesWithAssociationType:PFPropertyInfoAssociationTypeStrong],
30+
PFPushStatePropertyName(pushDate): [PFPropertyAttributes attributesWithAssociationType:PFPropertyInfoAssociationTypeStrong],
31+
PFPushStatePropertyName(payload): [PFPropertyAttributes attributesWithAssociationType:PFPropertyInfoAssociationTypeCopy] };
3032
}
3133

3234
///--------------------------------------
3335
#pragma mark - Init
3436
///--------------------------------------
3537

36-
- (instancetype)initWithState:(PFPushState *)state {
38+
- (instancetype)initWithState:(nullable PFPushState *)state {
3739
return [super initWithState:state];
3840
}
3941

40-
+ (instancetype)stateWithState:(PFPushState *)state {
42+
+ (instancetype)stateWithState:(nullable PFPushState *)state {
4143
return [super stateWithState:state];
4244
}
4345

4446
///--------------------------------------
4547
#pragma mark - NSCopying
4648
///--------------------------------------
4749

48-
- (void)setPushDate:(NSDate *)pushDate {
50+
- (void)setPushDate:(nullable NSDate *)pushDate {
4951
if (self.pushDate != pushDate) {
5052
NSTimeInterval interval = pushDate.timeIntervalSinceNow;
5153
PFParameterAssert(interval > 0, @"Can't set the scheduled push time in the past.");
@@ -58,16 +60,18 @@ - (void)setPushDate:(NSDate *)pushDate {
5860
#pragma mark - NSCopying
5961
///--------------------------------------
6062

61-
- (id)copyWithZone:(NSZone *)zone {
63+
- (id)copyWithZone:(nullable NSZone *)zone {
6264
return [[PFPushState allocWithZone:zone] initWithState:self];
6365
}
6466

6567
///--------------------------------------
6668
#pragma mark - NSMutableCopying
6769
///--------------------------------------
6870

69-
- (id)mutableCopyWithZone:(NSZone *)zone {
71+
- (id)mutableCopyWithZone:(nullable NSZone *)zone {
7072
return [[PFMutablePushState allocWithZone:zone] initWithState:self];
7173
}
7274

7375
@end
76+
77+
NS_ASSUME_NONNULL_END

Parse/Internal/Push/State/PFPushState_Private.h

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

1010
#import "PFPushState.h"
1111

12+
/**
13+
Returns NSString representation of a property.
14+
15+
@param NAME The name of the property.
16+
17+
@return NSString representation of a given property.
18+
*/
19+
#define PFPushStatePropertyName(NAME) @keypath(PFPushState, NAME)
20+
1221
NS_ASSUME_NONNULL_BEGIN
1322

1423
@interface PFPushState ()

0 commit comments

Comments
 (0)