Skip to content

Commit be24dbf

Browse files
committed
Merge pull request #54 from ParsePlatform/nlutsenko.locale
Unpublicize localeIdentifier property on PFInstallation.
2 parents bbd1fe6 + d346d63 commit be24dbf

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

Parse/Internal/Installation/PFInstallationPrivate.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,5 @@
2424
@property (nonatomic, copy, readwrite) NSString *deviceType;
2525
@property (nonatomic, copy, readwrite) NSString *installationId;
2626
@property (nonatomic, copy, readwrite) NSString *timeZone;
27-
@property (nonatomic, copy, readwrite) NSString *localeIdentifier;
2827

2928
@end

Parse/PFInstallation.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,6 @@ PF_ASSUME_NONNULL_BEGIN
7979
*/
8080
@property (PF_NULLABLE_PROPERTY nonatomic, copy, readonly) NSString *timeZone;
8181

82-
/*!
83-
@abstract The localeIdentifier for the `PFInstallation` ([language code]-[COUNTRY CODE]).
84-
*/
85-
@property (PF_NULLABLE_PROPERTY nonatomic, copy, readonly) NSString *localeIdentifier;
86-
8782
/*!
8883
@abstract The channels for the `PFInstallation`.
8984
*/

Parse/PFInstallation.m

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ @implementation PFInstallation
108108
@dynamic installationId;
109109
@dynamic deviceToken;
110110
@dynamic timeZone;
111-
@dynamic localeIdentifier;
112111
@dynamic channels;
113112
@dynamic badge;
114113

@@ -336,8 +335,10 @@ - (void)_updateLocaleIdentifierFromDevice {
336335
localeIdentifier = language;
337336
}
338337

339-
if (localeIdentifier.length > 0 && ![localeIdentifier isEqualToString:self.localeIdentifier]) {
340-
self.localeIdentifier = localeIdentifier;
338+
NSString *currentLocaleIdentifier = self[PFInstallationKeyLocaleIdentifier];
339+
if (localeIdentifier.length > 0 && ![localeIdentifier isEqualToString:currentLocaleIdentifier]) {
340+
// Call into super to avoid checking on protected keys.
341+
[super setObject:localeIdentifier forKey:PFInstallationKeyLocaleIdentifier];
341342
}
342343
}
343344

Tests/Unit/InstallationUnitTests.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ - (void)testInstallationImmutableFieldsCannotBeChanged {
3131
@"Should throw an exception for trying to change deviceType.");
3232
PFAssertThrowsInvalidArgumentException(installation[@"installationId"] = @"a"
3333
@"Should throw an exception for trying to change installationId.");
34+
PFAssertThrowsInvalidArgumentException(installation[@"localeIdentifier"] = @"a"
35+
@"Should throw an exception for trying to change installationId.");
3436
}
3537

3638
- (void)testInstallationImmutableFieldsCannotBeDeleted {
@@ -41,6 +43,8 @@ - (void)testInstallationImmutableFieldsCannotBeDeleted {
4143
@"Should throw an exception for trying to delete deviceType.");
4244
PFAssertThrowsInvalidArgumentException([installation removeObjectForKey:@"installationId"],
4345
@"Should throw an exception for trying to delete installationId.");
46+
PFAssertThrowsInvalidArgumentException([installation removeObjectForKey:@"localeIdentifier"],
47+
@"Should throw an exception for trying to delete installationId.");
4448
}
4549

4650
@end

0 commit comments

Comments
 (0)