Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class properties #1400

Merged
merged 3 commits into from
Apr 13, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 11 additions & 20 deletions Parse/Parse/Parse.h
Original file line number Diff line number Diff line change
@@ -104,17 +104,21 @@ NS_ASSUME_NONNULL_BEGIN

@return The current configuration in use by the SDK. Returns nil if the SDK has not been initialized yet.
*/
+ (nullable ParseClientConfiguration *)currentConfiguration;
@property (nonatomic, nullable, readonly, class) ParseClientConfiguration *currentConfiguration;

/**
The current application id that was used to configure Parse framework.
*/
+ (NSString *)getApplicationId;
@property (nonatomic, nonnull, readonly, class) NSString *applicationId;

+ (NSString *)getApplicationId PARSE_DEPRECATED("Use applicationId property.");

/**
The current client key that was used to configure Parse framework.
*/
+ (nullable NSString *)getClientKey;
@property (nonatomic, nullable, readonly, class) NSString *clientKey;

+ (nullable NSString *)getClientKey PARSE_DEPRECATED("Use clientKey property.");

///--------------------------------------
#pragma mark - Enabling Local Datastore
@@ -128,10 +132,10 @@ NS_ASSUME_NONNULL_BEGIN

/**
Flag that indicates whether Local Datastore is enabled.

@return `YES` if Local Datastore is enabled, otherwise `NO`.
*/
+ (BOOL)isLocalDatastoreEnabled PF_TV_UNAVAILABLE;
@property (nonatomic, readonly, class) BOOL isLocalDatastoreEnabled PF_TV_UNAVAILABLE;

///--------------------------------------
#pragma mark - Enabling Extensions Data Sharing
@@ -211,29 +215,16 @@ NS_ASSUME_NONNULL_BEGIN
///--------------------------------------

/**
Sets the level of logging to display.
Gets or sets the level of logging to display.

By default:
- If running inside an app that was downloaded from iOS App Store - it is set to `PFLogLevelNone`
- All other cases - it is set to `PFLogLevelWarning`

@param logLevel Log level to set.
@see PFLogLevel
*/
+ (void)setLogLevel:(PFLogLevel)logLevel;

/**
Log level that will be displayed.

By default:

- If running inside an app that was downloaded from iOS App Store - it is set to `PFLogLevelNone`
- All other cases - it is set to `PFLogLevelWarning`

@return A `PFLogLevel` value.
@see PFLogLevel
*/
+ (PFLogLevel)logLevel;
@property (nonatomic, readwrite, class) PFLogLevel logLevel;

@end

12 changes: 10 additions & 2 deletions Parse/Parse/Parse.m
Original file line number Diff line number Diff line change
@@ -93,18 +93,26 @@ + (nullable ParseClientConfiguration *)currentConfiguration {
return currentParseManager_.configuration;
}

+ (NSString *)getApplicationId {
+ (NSString *)applicationId {
PFConsistencyAssert(currentParseManager_,
@"You have to call setApplicationId:clientKey: on Parse to configure Parse.");
return currentParseManager_.configuration.applicationId;
}

+ (nullable NSString *)getClientKey {
+ (NSString *)getApplicationId {
return [self applicationId];
}

+ (nullable NSString *)clientKey {
PFConsistencyAssert(currentParseManager_,
@"You have to call setApplicationId:clientKey: on Parse to configure Parse.");
return currentParseManager_.configuration.clientKey;
}

+ (nullable NSString *)getClientKey {
return [self clientKey];
}

///--------------------------------------
#pragma mark - Extensions Data Sharing
///--------------------------------------
5 changes: 3 additions & 2 deletions Parse/Tests/Other/StoreKitMocking/PFTestSKProductsRequest.m
Original file line number Diff line number Diff line change
@@ -57,8 +57,9 @@ - (void)start {
invalidProductIdentifiers:[invalidProductIdentifiers allObjects]];

dispatch_async(dispatch_get_main_queue(), ^{
[self.delegate productsRequest:self didReceiveResponse:response];
[self.delegate requestDidFinish:self];
id<SKProductsRequestDelegate> delegate = self.delegate;
[delegate productsRequest:self didReceiveResponse:response];
[delegate requestDidFinish:self];
});
});
}
8 changes: 4 additions & 4 deletions Parse/Tests/Unit/CommandUnitTests.m
Original file line number Diff line number Diff line change
@@ -55,8 +55,8 @@ - (void)testNoRetryOn400StatusCode {

NSError *error = nil;
PFURLSessionCommandRunner *commandRunner = [PFURLSessionCommandRunner commandRunnerWithDataSource:[Parse _currentManager]
applicationId:[Parse getApplicationId]
clientKey:[Parse getClientKey]
applicationId:[Parse applicationId]
clientKey:[Parse clientKey]
serverURL:[NSURL URLWithString:_ParseDefaultServerURLString]];
[[commandRunner runCommandAsync:command
withOptions:PFCommandRunningOptionRetryIfFailed] waitForResult:&error];
@@ -86,8 +86,8 @@ - (void)testRetryOn500StatusCode {

NSError *error = nil;
PFURLSessionCommandRunner *commandRunner = [PFURLSessionCommandRunner commandRunnerWithDataSource:[Parse _currentManager]
applicationId:[Parse getApplicationId]
clientKey:[Parse getClientKey]
applicationId:[Parse applicationId]
clientKey:[Parse clientKey]
serverURL:[NSURL URLWithString:_ParseDefaultServerURLString]];
commandRunner.initialRetryDelay = DBL_MIN;
[[commandRunner runCommandAsync:command
4 changes: 2 additions & 2 deletions Parse/Tests/Unit/ExtensionDataSharingTests.m
Original file line number Diff line number Diff line change
@@ -103,7 +103,7 @@ - (void)testMainAppUsesSharedContainer {

// Paths are different on iOS and OSX.
NSString *containerPath = [PFExtensionDataSharingTestHelper sharedTestDirectoryPathForGroupIdentifier:@"yolo"];
[self assertDirectory:containerPath hasContents:@{ @"Parse" : @{ [Parse getApplicationId] : @{ @"applicationId" : [NSNull null] } } } only:NO];
[self assertDirectory:containerPath hasContents:@{ @"Parse" : @{ [Parse applicationId] : @{ @"applicationId" : [NSNull null] } } } only:NO];
}

- (void)testExtensionUsesSharedContainer {
@@ -116,7 +116,7 @@ - (void)testExtensionUsesSharedContainer {

// Paths are different on iOS and OSX.
NSString *containerPath = [PFExtensionDataSharingTestHelper sharedTestDirectoryPathForGroupIdentifier:@"yolo"];
[self assertDirectory:containerPath hasContents:@{ @"Parse" : @{ [Parse getApplicationId] : @{ @"applicationId" : [NSNull null] } } } only:NO];
[self assertDirectory:containerPath hasContents:@{ @"Parse" : @{ [Parse applicationId] : @{ @"applicationId" : [NSNull null] } } } only:NO];
}

- (void)testMigratingDataFromMainSandbox {