From d346d6351a514910fff5949edacbb5f4c1d271a9 Mon Sep 17 00:00:00 2001 From: Nikita Lutsenko Date: Tue, 18 Aug 2015 23:12:41 -0700 Subject: [PATCH] Unpublicize localeIdentifier property on PFInstallation. --- Parse/Internal/Installation/PFInstallationPrivate.h | 1 - Parse/PFInstallation.h | 5 ----- Parse/PFInstallation.m | 7 ++++--- Tests/Unit/InstallationUnitTests.m | 4 ++++ 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Parse/Internal/Installation/PFInstallationPrivate.h b/Parse/Internal/Installation/PFInstallationPrivate.h index 52475e170..0e24f86a6 100644 --- a/Parse/Internal/Installation/PFInstallationPrivate.h +++ b/Parse/Internal/Installation/PFInstallationPrivate.h @@ -24,6 +24,5 @@ @property (nonatomic, copy, readwrite) NSString *deviceType; @property (nonatomic, copy, readwrite) NSString *installationId; @property (nonatomic, copy, readwrite) NSString *timeZone; -@property (nonatomic, copy, readwrite) NSString *localeIdentifier; @end diff --git a/Parse/PFInstallation.h b/Parse/PFInstallation.h index d9d14fe11..7907a751e 100644 --- a/Parse/PFInstallation.h +++ b/Parse/PFInstallation.h @@ -79,11 +79,6 @@ PF_ASSUME_NONNULL_BEGIN */ @property (PF_NULLABLE_PROPERTY nonatomic, copy, readonly) NSString *timeZone; -/*! - @abstract The localeIdentifier for the `PFInstallation` ([language code]-[COUNTRY CODE]). - */ -@property (PF_NULLABLE_PROPERTY nonatomic, copy, readonly) NSString *localeIdentifier; - /*! @abstract The channels for the `PFInstallation`. */ diff --git a/Parse/PFInstallation.m b/Parse/PFInstallation.m index 0404b30d0..61fe0049e 100644 --- a/Parse/PFInstallation.m +++ b/Parse/PFInstallation.m @@ -108,7 +108,6 @@ @implementation PFInstallation @dynamic installationId; @dynamic deviceToken; @dynamic timeZone; -@dynamic localeIdentifier; @dynamic channels; @dynamic badge; @@ -336,8 +335,10 @@ - (void)_updateLocaleIdentifierFromDevice { localeIdentifier = language; } - if (localeIdentifier.length > 0 && ![localeIdentifier isEqualToString:self.localeIdentifier]) { - self.localeIdentifier = localeIdentifier; + NSString *currentLocaleIdentifier = self[PFInstallationKeyLocaleIdentifier]; + if (localeIdentifier.length > 0 && ![localeIdentifier isEqualToString:currentLocaleIdentifier]) { + // Call into super to avoid checking on protected keys. + [super setObject:localeIdentifier forKey:PFInstallationKeyLocaleIdentifier]; } } diff --git a/Tests/Unit/InstallationUnitTests.m b/Tests/Unit/InstallationUnitTests.m index 8e29a9b2e..38674bfa7 100644 --- a/Tests/Unit/InstallationUnitTests.m +++ b/Tests/Unit/InstallationUnitTests.m @@ -31,6 +31,8 @@ - (void)testInstallationImmutableFieldsCannotBeChanged { @"Should throw an exception for trying to change deviceType."); PFAssertThrowsInvalidArgumentException(installation[@"installationId"] = @"a" @"Should throw an exception for trying to change installationId."); + PFAssertThrowsInvalidArgumentException(installation[@"localeIdentifier"] = @"a" + @"Should throw an exception for trying to change installationId."); } - (void)testInstallationImmutableFieldsCannotBeDeleted { @@ -41,6 +43,8 @@ - (void)testInstallationImmutableFieldsCannotBeDeleted { @"Should throw an exception for trying to delete deviceType."); PFAssertThrowsInvalidArgumentException([installation removeObjectForKey:@"installationId"], @"Should throw an exception for trying to delete installationId."); + PFAssertThrowsInvalidArgumentException([installation removeObjectForKey:@"localeIdentifier"], + @"Should throw an exception for trying to delete installationId."); } @end