| @@ -0,0 +1,42 @@ | ||
| /* | ||
| * Copyright (c) 2014, Facebook, Inc. | ||
| * All rights reserved. | ||
| * | ||
| * This source code is licensed under the BSD-style license found in the | ||
| * LICENSE file in the root directory of this source tree. An additional grant | ||
| * of patent rights can be found in the PATENTS file in the same directory. | ||
| * | ||
| */ | ||
|
|
||
| #import <Foundation/Foundation.h> | ||
|
|
||
| #import <Bolts/BFCancellationTokenRegistration.h> | ||
|
|
||
| NS_ASSUME_NONNULL_BEGIN | ||
|
|
||
| /*! | ||
| A block that will be called when a token is cancelled. | ||
| */ | ||
| typedef void(^BFCancellationBlock)(); | ||
|
|
||
| /*! | ||
| The consumer view of a CancellationToken. | ||
| Propagates notification that operations should be canceled. | ||
| A BFCancellationToken has methods to inspect whether the token has been cancelled. | ||
| */ | ||
| @interface BFCancellationToken : NSObject | ||
|
|
||
| /*! | ||
| Whether cancellation has been requested for this token source. | ||
| */ | ||
| @property (nonatomic, assign, readonly, getter=isCancellationRequested) BOOL cancellationRequested; | ||
|
|
||
| /*! | ||
| Register a block to be notified when the token is cancelled. | ||
| If the token is already cancelled the delegate will be notified immediately. | ||
| */ | ||
| - (BFCancellationTokenRegistration *)registerCancellationObserverWithBlock:(BFCancellationBlock)block; | ||
|
|
||
| @end | ||
|
|
||
| NS_ASSUME_NONNULL_END |
| @@ -0,0 +1,29 @@ | ||
| /* | ||
| * Copyright (c) 2014, Facebook, Inc. | ||
| * All rights reserved. | ||
| * | ||
| * This source code is licensed under the BSD-style license found in the | ||
| * LICENSE file in the root directory of this source tree. An additional grant | ||
| * of patent rights can be found in the PATENTS file in the same directory. | ||
| * | ||
| */ | ||
|
|
||
| #import <Foundation/Foundation.h> | ||
|
|
||
| NS_ASSUME_NONNULL_BEGIN | ||
|
|
||
| /*! | ||
| Represents the registration of a cancellation observer with a cancellation token. | ||
| Can be used to unregister the observer at a later time. | ||
| */ | ||
| @interface BFCancellationTokenRegistration : NSObject | ||
|
|
||
| /*! | ||
| Removes the cancellation observer registered with the token | ||
| and releases all resources associated with this registration. | ||
| */ | ||
| - (void)dispose; | ||
|
|
||
| @end | ||
|
|
||
| NS_ASSUME_NONNULL_END |
| @@ -0,0 +1,60 @@ | ||
| /* | ||
| * Copyright (c) 2014, Facebook, Inc. | ||
| * All rights reserved. | ||
| * | ||
| * This source code is licensed under the BSD-style license found in the | ||
| * LICENSE file in the root directory of this source tree. An additional grant | ||
| * of patent rights can be found in the PATENTS file in the same directory. | ||
| * | ||
| */ | ||
|
|
||
| #import <Foundation/Foundation.h> | ||
|
|
||
| NS_ASSUME_NONNULL_BEGIN | ||
|
|
||
| @class BFCancellationToken; | ||
|
|
||
| /*! | ||
| BFCancellationTokenSource represents the producer side of a CancellationToken. | ||
| Signals to a CancellationToken that it should be canceled. | ||
| It is a cancellation token that also has methods | ||
| for changing the state of a token by cancelling it. | ||
| */ | ||
| @interface BFCancellationTokenSource : NSObject | ||
|
|
||
| /*! | ||
| Creates a new cancellation token source. | ||
| */ | ||
| + (instancetype)cancellationTokenSource; | ||
|
|
||
| /*! | ||
| The cancellation token associated with this CancellationTokenSource. | ||
| */ | ||
| @property (nonatomic, strong, readonly) BFCancellationToken *token; | ||
|
|
||
| /*! | ||
| Whether cancellation has been requested for this token source. | ||
| */ | ||
| @property (nonatomic, assign, readonly, getter=isCancellationRequested) BOOL cancellationRequested; | ||
|
|
||
| /*! | ||
| Cancels the token if it has not already been cancelled. | ||
| */ | ||
| - (void)cancel; | ||
|
|
||
| /*! | ||
| Schedules a cancel operation on this CancellationTokenSource after the specified number of milliseconds. | ||
| @param millis The number of milliseconds to wait before completing the returned task. | ||
| If delay is `0` the cancel is executed immediately. If delay is `-1` any scheduled cancellation is stopped. | ||
| */ | ||
| - (void)cancelAfterDelay:(int)millis; | ||
|
|
||
| /*! | ||
| Releases all resources associated with this token source, | ||
| including disposing of all registrations. | ||
| */ | ||
| - (void)dispose; | ||
|
|
||
| @end | ||
|
|
||
| NS_ASSUME_NONNULL_END |
| @@ -0,0 +1,18 @@ | ||
| /* | ||
| * Copyright (c) 2014, Facebook, Inc. | ||
| * All rights reserved. | ||
| * | ||
| * This source code is licensed under the BSD-style license found in the | ||
| * LICENSE file in the root directory of this source tree. An additional grant | ||
| * of patent rights can be found in the PATENTS file in the same directory. | ||
| * | ||
| */ | ||
|
|
||
| #import <Foundation/Foundation.h> | ||
|
|
||
| #if __has_feature(objc_generics) || __has_extension(objc_generics) | ||
| # define BF_GENERIC(type) <type> | ||
| #else | ||
| # define BF_GENERIC(type) | ||
| # define BFGenericType id | ||
| #endif |
| @@ -0,0 +1,62 @@ | ||
| /* | ||
| * Copyright (c) 2014, Facebook, Inc. | ||
| * All rights reserved. | ||
| * | ||
| * This source code is licensed under the BSD-style license found in the | ||
| * LICENSE file in the root directory of this source tree. An additional grant | ||
| * of patent rights can be found in the PATENTS file in the same directory. | ||
| * | ||
| */ | ||
|
|
||
| #import <Foundation/Foundation.h> | ||
|
|
||
| NS_ASSUME_NONNULL_BEGIN | ||
|
|
||
| /*! | ||
| An object that can run a given block. | ||
| */ | ||
| @interface BFExecutor : NSObject | ||
|
|
||
| /*! | ||
| Returns a default executor, which runs continuations immediately until the call stack gets too | ||
| deep, then dispatches to a new GCD queue. | ||
| */ | ||
| + (instancetype)defaultExecutor; | ||
|
|
||
| /*! | ||
| Returns an executor that runs continuations on the thread where the previous task was completed. | ||
| */ | ||
| + (instancetype)immediateExecutor; | ||
|
|
||
| /*! | ||
| Returns an executor that runs continuations on the main thread. | ||
| */ | ||
| + (instancetype)mainThreadExecutor; | ||
|
|
||
| /*! | ||
| Returns a new executor that uses the given block to execute continuations. | ||
| @param block The block to use. | ||
| */ | ||
| + (instancetype)executorWithBlock:(void(^)(void(^block)()))block; | ||
|
|
||
| /*! | ||
| Returns a new executor that runs continuations on the given queue. | ||
| @param queue The instance of `dispatch_queue_t` to dispatch all continuations onto. | ||
| */ | ||
| + (instancetype)executorWithDispatchQueue:(dispatch_queue_t)queue; | ||
|
|
||
| /*! | ||
| Returns a new executor that runs continuations on the given queue. | ||
| @param queue The instance of `NSOperationQueue` to run all continuations on. | ||
| */ | ||
| + (instancetype)executorWithOperationQueue:(NSOperationQueue *)queue; | ||
|
|
||
| /*! | ||
| Runs the given block using this executor's particular strategy. | ||
| @param block The block to execute. | ||
| */ | ||
| - (void)execute:(void(^)())block; | ||
|
|
||
| @end | ||
|
|
||
| NS_ASSUME_NONNULL_END |
| @@ -0,0 +1,45 @@ | ||
| /* | ||
| * Copyright (c) 2014, Facebook, Inc. | ||
| * All rights reserved. | ||
| * | ||
| * This source code is licensed under the BSD-style license found in the | ||
| * LICENSE file in the root directory of this source tree. An additional grant | ||
| * of patent rights can be found in the PATENTS file in the same directory. | ||
| * | ||
| */ | ||
|
|
||
| #import <Foundation/Foundation.h> | ||
|
|
||
| /*! The name of the notification posted by BFMeasurementEvent */ | ||
| FOUNDATION_EXPORT NSString *const BFMeasurementEventNotificationName; | ||
|
|
||
| /*! Defines keys in the userInfo object for the notification named BFMeasurementEventNotificationName */ | ||
| /*! The string field for the name of the event */ | ||
| FOUNDATION_EXPORT NSString *const BFMeasurementEventNameKey; | ||
| /*! The dictionary field for the arguments of the event */ | ||
| FOUNDATION_EXPORT NSString *const BFMeasurementEventArgsKey; | ||
|
|
||
| /*! Bolts Events raised by BFMeasurementEvent for Applink */ | ||
| /*! | ||
| The name of the event posted when [BFURL URLWithURL:] is called successfully. This represents the successful parsing of an app link URL. | ||
| */ | ||
| FOUNDATION_EXPORT NSString *const BFAppLinkParseEventName; | ||
|
|
||
| /*! | ||
| The name of the event posted when [BFURL URLWithInboundURL:] is called successfully. | ||
| This represents parsing an inbound app link URL from a different application | ||
| */ | ||
| FOUNDATION_EXPORT NSString *const BFAppLinkNavigateInEventName; | ||
|
|
||
| /*! The event raised when the user navigates from your app to other apps */ | ||
| FOUNDATION_EXPORT NSString *const BFAppLinkNavigateOutEventName; | ||
|
|
||
| /*! | ||
| The event raised when the user navigates out from your app and back to the referrer app. | ||
| e.g when the user leaves your app after tapping the back-to-referrer navigation bar | ||
| */ | ||
| FOUNDATION_EXPORT NSString *const BFAppLinkNavigateBackToReferrerEventName; | ||
|
|
||
| @interface BFMeasurementEvent : NSObject | ||
|
|
||
| @end |
| @@ -0,0 +1,257 @@ | ||
| /* | ||
| * Copyright (c) 2014, Facebook, Inc. | ||
| * All rights reserved. | ||
| * | ||
| * This source code is licensed under the BSD-style license found in the | ||
| * LICENSE file in the root directory of this source tree. An additional grant | ||
| * of patent rights can be found in the PATENTS file in the same directory. | ||
| * | ||
| */ | ||
|
|
||
| #import <Foundation/Foundation.h> | ||
|
|
||
| #import <Bolts/BFCancellationToken.h> | ||
| #import <Bolts/BFDefines.h> | ||
|
|
||
| NS_ASSUME_NONNULL_BEGIN | ||
|
|
||
| /*! | ||
| Error domain used if there was multiple errors on <BFTask taskForCompletionOfAllTasks:>. | ||
| */ | ||
| extern NSString *const BFTaskErrorDomain; | ||
|
|
||
| /*! | ||
| An exception that is thrown if there was multiple exceptions on <BFTask taskForCompletionOfAllTasks:>. | ||
| */ | ||
| extern NSString *const BFTaskMultipleExceptionsException; | ||
|
|
||
| @class BFExecutor; | ||
| @class BFTask; | ||
|
|
||
| /*! | ||
| The consumer view of a Task. A BFTask has methods to | ||
| inspect the state of the task, and to add continuations to | ||
| be run once the task is complete. | ||
| */ | ||
| @interface BFTask BF_GENERIC(__covariant BFGenericType) : NSObject | ||
|
|
||
| /*! | ||
| A block that can act as a continuation for a task. | ||
| */ | ||
| typedef __nullable id(^BFContinuationBlock)(BFTask BF_GENERIC(BFGenericType) *task); | ||
|
|
||
| /*! | ||
| Creates a task that is already completed with the given result. | ||
| @param result The result for the task. | ||
| */ | ||
| + (instancetype)taskWithResult:(nullable BFGenericType)result; | ||
|
|
||
| /*! | ||
| Creates a task that is already completed with the given error. | ||
| @param error The error for the task. | ||
| */ | ||
| + (instancetype)taskWithError:(NSError *)error; | ||
|
|
||
| /*! | ||
| Creates a task that is already completed with the given exception. | ||
| @param exception The exception for the task. | ||
| */ | ||
| + (instancetype)taskWithException:(NSException *)exception; | ||
|
|
||
| /*! | ||
| Creates a task that is already cancelled. | ||
| */ | ||
| + (instancetype)cancelledTask; | ||
|
|
||
| /*! | ||
| Returns a task that will be completed (with result == nil) once | ||
| all of the input tasks have completed. | ||
| @param tasks An `NSArray` of the tasks to use as an input. | ||
| */ | ||
| + (instancetype)taskForCompletionOfAllTasks:(nullable NSArray *)tasks; | ||
|
|
||
| /*! | ||
| Returns a task that will be completed once all of the input tasks have completed. | ||
| If all tasks complete successfully without being faulted or cancelled the result will be | ||
| an `NSArray` of all task results in the order they were provided. | ||
| @param tasks An `NSArray` of the tasks to use as an input. | ||
| */ | ||
| + (instancetype)taskForCompletionOfAllTasksWithResults:(nullable NSArray *)tasks; | ||
|
|
||
| /*! | ||
| Returns a task that will be completed a certain amount of time in the future. | ||
| @param millis The approximate number of milliseconds to wait before the | ||
| task will be finished (with result == nil). | ||
| */ | ||
| + (instancetype)taskWithDelay:(int)millis; | ||
|
|
||
| /*! | ||
| Returns a task that will be completed a certain amount of time in the future. | ||
| @param millis The approximate number of milliseconds to wait before the | ||
| task will be finished (with result == nil). | ||
| @param token The cancellation token (optional). | ||
| */ | ||
| + (instancetype)taskWithDelay:(int)millis cancellationToken:(nullable BFCancellationToken *)token; | ||
|
|
||
| /*! | ||
| Returns a task that will be completed after the given block completes with | ||
| the specified executor. | ||
| @param executor A BFExecutor responsible for determining how the | ||
| continuation block will be run. | ||
| @param block The block to immediately schedule to run with the given executor. | ||
| @returns A task that will be completed after block has run. | ||
| If block returns a BFTask, then the task returned from | ||
| this method will not be completed until that task is completed. | ||
| */ | ||
| + (instancetype)taskFromExecutor:(BFExecutor *)executor withBlock:(id (^)())block; | ||
|
|
||
| // Properties that will be set on the task once it is completed. | ||
|
|
||
| /*! | ||
| The result of a successful task. | ||
| */ | ||
| @property (nullable, nonatomic, strong, readonly) BFGenericType result; | ||
|
|
||
| /*! | ||
| The error of a failed task. | ||
| */ | ||
| @property (nullable, nonatomic, strong, readonly) NSError *error; | ||
|
|
||
| /*! | ||
| The exception of a failed task. | ||
| */ | ||
| @property (nullable, nonatomic, strong, readonly) NSException *exception; | ||
|
|
||
| /*! | ||
| Whether this task has been cancelled. | ||
| */ | ||
| @property (nonatomic, assign, readonly, getter=isCancelled) BOOL cancelled; | ||
|
|
||
| /*! | ||
| Whether this task has completed due to an error or exception. | ||
| */ | ||
| @property (nonatomic, assign, readonly, getter=isFaulted) BOOL faulted; | ||
|
|
||
| /*! | ||
| Whether this task has completed. | ||
| */ | ||
| @property (nonatomic, assign, readonly, getter=isCompleted) BOOL completed; | ||
|
|
||
| /*! | ||
| Enqueues the given block to be run once this task is complete. | ||
| This method uses a default execution strategy. The block will be | ||
| run on the thread where the previous task completes, unless the | ||
| the stack depth is too deep, in which case it will be run on a | ||
| dispatch queue with default priority. | ||
| @param block The block to be run once this task is complete. | ||
| @returns A task that will be completed after block has run. | ||
| If block returns a BFTask, then the task returned from | ||
| this method will not be completed until that task is completed. | ||
| */ | ||
| - (BFTask *)continueWithBlock:(BFContinuationBlock)block; | ||
|
|
||
| /*! | ||
| Enqueues the given block to be run once this task is complete. | ||
| This method uses a default execution strategy. The block will be | ||
| run on the thread where the previous task completes, unless the | ||
| the stack depth is too deep, in which case it will be run on a | ||
| dispatch queue with default priority. | ||
| @param block The block to be run once this task is complete. | ||
| @param cancellationToken The cancellation token (optional). | ||
| @returns A task that will be completed after block has run. | ||
| If block returns a BFTask, then the task returned from | ||
| this method will not be completed until that task is completed. | ||
| */ | ||
| - (BFTask *)continueWithBlock:(BFContinuationBlock)block cancellationToken:(nullable BFCancellationToken *)cancellationToken; | ||
|
|
||
| /*! | ||
| Enqueues the given block to be run once this task is complete. | ||
| @param executor A BFExecutor responsible for determining how the | ||
| continuation block will be run. | ||
| @param block The block to be run once this task is complete. | ||
| @returns A task that will be completed after block has run. | ||
| If block returns a BFTask, then the task returned from | ||
| this method will not be completed until that task is completed. | ||
| */ | ||
| - (BFTask *)continueWithExecutor:(BFExecutor *)executor withBlock:(BFContinuationBlock)block; | ||
| /*! | ||
| Enqueues the given block to be run once this task is complete. | ||
| @param executor A BFExecutor responsible for determining how the | ||
| continuation block will be run. | ||
| @param block The block to be run once this task is complete. | ||
| @param cancellationToken The cancellation token (optional). | ||
| @returns A task that will be completed after block has run. | ||
| If block returns a BFTask, then the task returned from | ||
| his method will not be completed until that task is completed. | ||
| */ | ||
| - (BFTask *)continueWithExecutor:(BFExecutor *)executor | ||
| block:(BFContinuationBlock)block | ||
| cancellationToken:(nullable BFCancellationToken *)cancellationToken; | ||
|
|
||
| /*! | ||
| Identical to continueWithBlock:, except that the block is only run | ||
| if this task did not produce a cancellation, error, or exception. | ||
| If it did, then the failure will be propagated to the returned | ||
| task. | ||
| @param block The block to be run once this task is complete. | ||
| @returns A task that will be completed after block has run. | ||
| If block returns a BFTask, then the task returned from | ||
| this method will not be completed until that task is completed. | ||
| */ | ||
| - (BFTask *)continueWithSuccessBlock:(BFContinuationBlock)block; | ||
|
|
||
| /*! | ||
| Identical to continueWithBlock:, except that the block is only run | ||
| if this task did not produce a cancellation, error, or exception. | ||
| If it did, then the failure will be propagated to the returned | ||
| task. | ||
| @param block The block to be run once this task is complete. | ||
| @param cancellationToken The cancellation token (optional). | ||
| @returns A task that will be completed after block has run. | ||
| If block returns a BFTask, then the task returned from | ||
| this method will not be completed until that task is completed. | ||
| */ | ||
| - (BFTask *)continueWithSuccessBlock:(BFContinuationBlock)block cancellationToken:(nullable BFCancellationToken *)cancellationToken; | ||
|
|
||
| /*! | ||
| Identical to continueWithExecutor:withBlock:, except that the block | ||
| is only run if this task did not produce a cancellation, error, or | ||
| exception. If it did, then the failure will be propagated to the | ||
| returned task. | ||
| @param executor A BFExecutor responsible for determining how the | ||
| continuation block will be run. | ||
| @param block The block to be run once this task is complete. | ||
| @returns A task that will be completed after block has run. | ||
| If block returns a BFTask, then the task returned from | ||
| this method will not be completed until that task is completed. | ||
| */ | ||
| - (BFTask *)continueWithExecutor:(BFExecutor *)executor withSuccessBlock:(BFContinuationBlock)block; | ||
|
|
||
| /*! | ||
| Identical to continueWithExecutor:withBlock:, except that the block | ||
| is only run if this task did not produce a cancellation, error, or | ||
| exception. If it did, then the failure will be propagated to the | ||
| returned task. | ||
| @param executor A BFExecutor responsible for determining how the | ||
| continuation block will be run. | ||
| @param block The block to be run once this task is complete. | ||
| @param cancellationToken The cancellation token (optional). | ||
| @returns A task that will be completed after block has run. | ||
| If block returns a BFTask, then the task returned from | ||
| this method will not be completed until that task is completed. | ||
| */ | ||
| - (BFTask *)continueWithExecutor:(BFExecutor *)executor | ||
| successBlock:(BFContinuationBlock)block | ||
| cancellationToken:(nullable BFCancellationToken *)cancellationToken; | ||
|
|
||
| /*! | ||
| Waits until this operation is completed. | ||
| This method is inefficient and consumes a thread resource while | ||
| it's running. It should be avoided. This method logs a warning | ||
| message if it is used on the main thread. | ||
| */ | ||
| - (void)waitUntilFinished; | ||
|
|
||
| @end | ||
|
|
||
| NS_ASSUME_NONNULL_END |
| @@ -0,0 +1,91 @@ | ||
| /* | ||
| * Copyright (c) 2014, Facebook, Inc. | ||
| * All rights reserved. | ||
| * | ||
| * This source code is licensed under the BSD-style license found in the | ||
| * LICENSE file in the root directory of this source tree. An additional grant | ||
| * of patent rights can be found in the PATENTS file in the same directory. | ||
| * | ||
| */ | ||
|
|
||
| #import <Foundation/Foundation.h> | ||
|
|
||
| #import <Bolts/BFDefines.h> | ||
|
|
||
| NS_ASSUME_NONNULL_BEGIN | ||
|
|
||
| @class BFTask BF_GENERIC(BFGenericType); | ||
|
|
||
| /*! | ||
| A BFTaskCompletionSource represents the producer side of tasks. | ||
| It is a task that also has methods for changing the state of the | ||
| task by settings its completion values. | ||
| */ | ||
| @interface BFTaskCompletionSource BF_GENERIC(__covariant BFGenericType) : NSObject | ||
|
|
||
| /*! | ||
| Creates a new unfinished task. | ||
| */ | ||
| + (instancetype)taskCompletionSource; | ||
|
|
||
| /*! | ||
| The task associated with this TaskCompletionSource. | ||
| */ | ||
| @property (nonatomic, strong, readonly) BFTask BF_GENERIC(BFGenericType) *task; | ||
|
|
||
| /*! | ||
| Completes the task by setting the result. | ||
| Attempting to set this for a completed task will raise an exception. | ||
| @param result The result of the task. | ||
| */ | ||
| - (void)setResult:(nullable BFGenericType)result; | ||
|
|
||
| /*! | ||
| Completes the task by setting the error. | ||
| Attempting to set this for a completed task will raise an exception. | ||
| @param error The error for the task. | ||
| */ | ||
| - (void)setError:(NSError *)error; | ||
|
|
||
| /*! | ||
| Completes the task by setting an exception. | ||
| Attempting to set this for a completed task will raise an exception. | ||
| @param exception The exception for the task. | ||
| */ | ||
| - (void)setException:(NSException *)exception; | ||
|
|
||
| /*! | ||
| Completes the task by marking it as cancelled. | ||
| Attempting to set this for a completed task will raise an exception. | ||
| */ | ||
| - (void)cancel; | ||
|
|
||
| /*! | ||
| Sets the result of the task if it wasn't already completed. | ||
| @returns whether the new value was set. | ||
| */ | ||
| - (BOOL)trySetResult:(nullable BFGenericType)result; | ||
|
|
||
| /*! | ||
| Sets the error of the task if it wasn't already completed. | ||
| @param error The error for the task. | ||
| @returns whether the new value was set. | ||
| */ | ||
| - (BOOL)trySetError:(NSError *)error; | ||
|
|
||
| /*! | ||
| Sets the exception of the task if it wasn't already completed. | ||
| @param exception The exception for the task. | ||
| @returns whether the new value was set. | ||
| */ | ||
| - (BOOL)trySetException:(NSException *)exception; | ||
|
|
||
| /*! | ||
| Sets the cancellation state of the task if it wasn't already completed. | ||
| @returns whether the new value was set. | ||
| */ | ||
| - (BOOL)trySetCancelled; | ||
|
|
||
| @end | ||
|
|
||
| NS_ASSUME_NONNULL_END |
| @@ -0,0 +1,75 @@ | ||
| /* | ||
| * Copyright (c) 2014, Facebook, Inc. | ||
| * All rights reserved. | ||
| * | ||
| * This source code is licensed under the BSD-style license found in the | ||
| * LICENSE file in the root directory of this source tree. An additional grant | ||
| * of patent rights can be found in the PATENTS file in the same directory. | ||
| * | ||
| */ | ||
|
|
||
| #import <Foundation/Foundation.h> | ||
|
|
||
| @class BFAppLink; | ||
|
|
||
| /*! | ||
| Provides a set of utilities for working with NSURLs, such as parsing of query parameters | ||
| and handling for App Link requests. | ||
| */ | ||
| @interface BFURL : NSObject | ||
|
|
||
| /*! | ||
| Creates a link target from a raw URL. | ||
| On success, this posts the BFAppLinkParseEventName measurement event. If you are constructing the BFURL within your application delegate's | ||
| application:openURL:sourceApplication:annotation:, you should instead use URLWithInboundURL:sourceApplication: | ||
| to support better BFMeasurementEvent notifications | ||
| @param url The instance of `NSURL` to create BFURL from. | ||
| */ | ||
| + (BFURL *)URLWithURL:(NSURL *)url; | ||
|
|
||
| /*! | ||
| Creates a link target from a raw URL received from an external application. This is typically called from the app delegate's | ||
| application:openURL:sourceApplication:annotation: and will post the BFAppLinkNavigateInEventName measurement event. | ||
| @param url The instance of `NSURL` to create BFURL from. | ||
| @param sourceApplication the bundle ID of the app that is requesting your app to open the URL. The same sourceApplication in application:openURL:sourceApplication:annotation: | ||
| */ | ||
| + (BFURL *)URLWithInboundURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication; | ||
|
|
||
| /*! | ||
| Gets the target URL. If the link is an App Link, this is the target of the App Link. | ||
| Otherwise, it is the url that created the target. | ||
| */ | ||
| @property (nonatomic, strong, readonly) NSURL *targetURL; | ||
|
|
||
| /*! | ||
| Gets the query parameters for the target, parsed into an NSDictionary. | ||
| */ | ||
| @property (nonatomic, strong, readonly) NSDictionary *targetQueryParameters; | ||
|
|
||
| /*! | ||
| If this link target is an App Link, this is the data found in al_applink_data. | ||
| Otherwise, it is nil. | ||
| */ | ||
| @property (nonatomic, strong, readonly) NSDictionary *appLinkData; | ||
|
|
||
| /*! | ||
| If this link target is an App Link, this is the data found in extras. | ||
| */ | ||
| @property (nonatomic, strong, readonly) NSDictionary *appLinkExtras; | ||
|
|
||
| /*! | ||
| The App Link indicating how to navigate back to the referer app, if any. | ||
| */ | ||
| @property (nonatomic, strong, readonly) BFAppLink *appLinkReferer; | ||
|
|
||
| /*! | ||
| The URL that was used to create this BFURL. | ||
| */ | ||
| @property (nonatomic, strong, readonly) NSURL *inputURL; | ||
|
|
||
| /*! | ||
| The query parameters of the inputURL, parsed into an NSDictionary. | ||
| */ | ||
| @property (nonatomic, strong, readonly) NSDictionary *inputQueryParameters; | ||
|
|
||
| @end |
| @@ -0,0 +1,26 @@ | ||
| /* | ||
| * Copyright (c) 2014, Facebook, Inc. | ||
| * All rights reserved. | ||
| * | ||
| * This source code is licensed under the BSD-style license found in the | ||
| * LICENSE file in the root directory of this source tree. An additional grant | ||
| * of patent rights can be found in the PATENTS file in the same directory. | ||
| * | ||
| */ | ||
|
|
||
| #import <Foundation/Foundation.h> | ||
|
|
||
| #import <Bolts/BFAppLinkResolving.h> | ||
|
|
||
| /*! | ||
| A reference implementation for an App Link resolver that uses a hidden UIWebView | ||
| to parse the HTML containing App Link metadata. | ||
| */ | ||
| @interface BFWebViewAppLinkResolver : NSObject <BFAppLinkResolving> | ||
|
|
||
| /*! | ||
| Gets the instance of a BFWebViewAppLinkResolver. | ||
| */ | ||
| + (instancetype)sharedInstance; | ||
|
|
||
| @end |
| @@ -0,0 +1,47 @@ | ||
| /* | ||
| * Copyright (c) 2014, Facebook, Inc. | ||
| * All rights reserved. | ||
| * | ||
| * This source code is licensed under the BSD-style license found in the | ||
| * LICENSE file in the root directory of this source tree. An additional grant | ||
| * of patent rights can be found in the PATENTS file in the same directory. | ||
| * | ||
| */ | ||
|
|
||
| #import <Bolts/BoltsVersion.h> | ||
| #import <Bolts/BFCancellationToken.h> | ||
| #import <Bolts/BFCancellationTokenRegistration.h> | ||
| #import <Bolts/BFCancellationTokenSource.h> | ||
| #import <Bolts/BFDefines.h> | ||
| #import <Bolts/BFExecutor.h> | ||
| #import <Bolts/BFTask.h> | ||
| #import <Bolts/BFTaskCompletionSource.h> | ||
|
|
||
| #if __has_include(<Bolts/BFAppLink.h>) && TARGET_OS_IPHONE && !TARGET_OS_WATCH && !TARGET_OS_TV | ||
| #import <Bolts/BFAppLink.h> | ||
| #import <Bolts/BFAppLinkNavigation.h> | ||
| #import <Bolts/BFAppLinkResolving.h> | ||
| #import <Bolts/BFAppLinkReturnToRefererController.h> | ||
| #import <Bolts/BFAppLinkReturnToRefererView.h> | ||
| #import <Bolts/BFAppLinkTarget.h> | ||
| #import <Bolts/BFMeasurementEvent.h> | ||
| #import <Bolts/BFURL.h> | ||
| #import <Bolts/BFWebViewAppLinkResolver.h> | ||
| #endif | ||
|
|
||
| NS_ASSUME_NONNULL_BEGIN | ||
|
|
||
| /*! @abstract 80175001: There were multiple errors. */ | ||
| extern NSInteger const kBFMultipleErrorsError; | ||
|
|
||
| @interface Bolts : NSObject | ||
|
|
||
| /*! | ||
| Returns the version of the Bolts Framework as an NSString. | ||
| @returns The NSString representation of the current version. | ||
| */ | ||
| + (NSString *)version; | ||
|
|
||
| @end | ||
|
|
||
| NS_ASSUME_NONNULL_END |
| @@ -0,0 +1 @@ | ||
| #define BOLTS_VERSION @"1.5.1" |
| @@ -0,0 +1,15 @@ | ||
| framework module Bolts { | ||
| umbrella header "Bolts.h" | ||
|
|
||
| export * | ||
| module * { export * } | ||
|
|
||
| explicit module BFAppLinkResolving { | ||
| header "BFAppLinkResolving.h" | ||
| export * | ||
| } | ||
| explicit module BFWebViewAppLinkResolver { | ||
| header "BFWebViewAppLinkResolver.h" | ||
| export * | ||
| } | ||
| } |
| @@ -9,5 +9,6 @@ | ||
| #import <UIKit/UIKit.h> | ||
|
|
||
| @interface DesiredLearningOutcomesTableViewCell : UITableViewCell | ||
| @property (weak, nonatomic) IBOutlet UILabel *outcomeLabel; | ||
|
|
||
| @end | ||
| @@ -8,6 +8,6 @@ | ||
|
|
||
| #import <UIKit/UIKit.h> | ||
|
|
||
| @interface HighElementsTableViewController : UITableViewController<UISearchBarDelegate> | ||
|
|
||
| @end | ||
| @@ -8,6 +8,6 @@ | ||
|
|
||
| #import <UIKit/UIKit.h> | ||
|
|
||
| @interface LowElementsTableViewController : UITableViewController<UISearchBarDelegate> | ||
| @property (strong, nonatomic) NSArray *lowElementsArray; | ||
| @end | ||
| @@ -0,0 +1,244 @@ | ||
| /** | ||
| * Copyright (c) 2015-present, Parse, LLC. | ||
| * All rights reserved. | ||
| * | ||
| * This source code is licensed under the BSD-style license found in the | ||
| * LICENSE file in the root directory of this source tree. An additional grant | ||
| * of patent rights can be found in the PATENTS file in the same directory. | ||
| */ | ||
|
|
||
| #import <Foundation/Foundation.h> | ||
|
|
||
| NS_ASSUME_NONNULL_BEGIN | ||
|
|
||
| @class PFRole; | ||
| @class PFUser; | ||
|
|
||
| /** | ||
| The `PFACL` class is used to control which users can access or modify a particular object. | ||
| Each `PFObject` can have its own `PFACL`. You can grant read and write permissions separately to specific users, | ||
| to groups of users that belong to roles, or you can grant permissions to "the public" so that, | ||
| for example, any user could read a particular object but only a particular set of users could write to that object. | ||
| */ | ||
| @interface PFACL : NSObject <NSCopying, NSCoding> | ||
|
|
||
| ///-------------------------------------- | ||
| #pragma mark - Creating an ACL | ||
| ///-------------------------------------- | ||
|
|
||
| /** | ||
| Creates an ACL with no permissions granted. | ||
| @return Returns a new `PFACL`. | ||
| */ | ||
| + (instancetype)ACL; | ||
|
|
||
| /** | ||
| Creates an ACL where only the provided user has access. | ||
| @param user The user to assign access. | ||
| */ | ||
| + (instancetype)ACLWithUser:(PFUser *)user; | ||
|
|
||
| ///-------------------------------------- | ||
| #pragma mark - Controlling Public Access | ||
| ///-------------------------------------- | ||
|
|
||
| /** | ||
| Controls whether the public is allowed to read this object. | ||
| */ | ||
| @property (nonatomic, assign, getter=getPublicReadAccess) BOOL publicReadAccess; | ||
|
|
||
| /** | ||
| Controls whether the public is allowed to write this object. | ||
| */ | ||
| @property (nonatomic, assign, getter=getPublicWriteAccess) BOOL publicWriteAccess; | ||
|
|
||
| ///-------------------------------------- | ||
| #pragma mark - Controlling Access Per-User | ||
| ///-------------------------------------- | ||
|
|
||
| /** | ||
| Set whether the given user id is allowed to read this object. | ||
| @param allowed Whether the given user can write this object. | ||
| @param userId The `PFObject.objectId` of the user to assign access. | ||
| */ | ||
| - (void)setReadAccess:(BOOL)allowed forUserId:(NSString *)userId; | ||
|
|
||
| /** | ||
| Gets whether the given user id is *explicitly* allowed to read this object. | ||
| Even if this returns `NO`, the user may still be able to access it if `publicReadAccess` returns `YES` | ||
| or if the user belongs to a role that has access. | ||
| @param userId The `PFObject.objectId` of the user for which to retrive access. | ||
| @return `YES` if the user with this `objectId` has *explicit* read access, otherwise `NO`. | ||
| */ | ||
| - (BOOL)getReadAccessForUserId:(NSString *)userId; | ||
|
|
||
| /** | ||
| Set whether the given user id is allowed to write this object. | ||
| @param allowed Whether the given user can read this object. | ||
| @param userId The `PFObject.objectId` of the user to assign access. | ||
| */ | ||
| - (void)setWriteAccess:(BOOL)allowed forUserId:(NSString *)userId; | ||
|
|
||
| /** | ||
| Gets whether the given user id is *explicitly* allowed to write this object. | ||
| Even if this returns NO, the user may still be able to write it if `publicWriteAccess` returns `YES` | ||
| or if the user belongs to a role that has access. | ||
| @param userId The `PFObject.objectId` of the user for which to retrive access. | ||
| @return `YES` if the user with this `PFObject.objectId` has *explicit* write access, otherwise `NO`. | ||
| */ | ||
| - (BOOL)getWriteAccessForUserId:(NSString *)userId; | ||
|
|
||
| /** | ||
| Set whether the given user is allowed to read this object. | ||
| @param allowed Whether the given user can read this object. | ||
| @param user The user to assign access. | ||
| */ | ||
| - (void)setReadAccess:(BOOL)allowed forUser:(PFUser *)user; | ||
|
|
||
| /** | ||
| Gets whether the given user is *explicitly* allowed to read this object. | ||
| Even if this returns `NO`, the user may still be able to access it if `publicReadAccess` returns `YES` | ||
| or if the user belongs to a role that has access. | ||
| @param user The user for which to retrive access. | ||
| @return `YES` if the user has *explicit* read access, otherwise `NO`. | ||
| */ | ||
| - (BOOL)getReadAccessForUser:(PFUser *)user; | ||
|
|
||
| /** | ||
| Set whether the given user is allowed to write this object. | ||
| @param allowed Whether the given user can write this object. | ||
| @param user The user to assign access. | ||
| */ | ||
| - (void)setWriteAccess:(BOOL)allowed forUser:(PFUser *)user; | ||
|
|
||
| /** | ||
| Gets whether the given user is *explicitly* allowed to write this object. | ||
| Even if this returns `NO`, the user may still be able to write it if `publicWriteAccess` returns `YES` | ||
| or if the user belongs to a role that has access. | ||
| @param user The user for which to retrive access. | ||
| @return `YES` if the user has *explicit* write access, otherwise `NO`. | ||
| */ | ||
| - (BOOL)getWriteAccessForUser:(PFUser *)user; | ||
|
|
||
| ///-------------------------------------- | ||
| #pragma mark - Controlling Access Per-Role | ||
| ///-------------------------------------- | ||
|
|
||
| /** | ||
| Get whether users belonging to the role with the given name are allowed to read this object. | ||
| Even if this returns `NO`, the role may still be able to read it if a parent role has read access. | ||
| @param name The name of the role. | ||
| @return `YES` if the role has read access, otherwise `NO`. | ||
| */ | ||
| - (BOOL)getReadAccessForRoleWithName:(NSString *)name; | ||
|
|
||
| /** | ||
| Set whether users belonging to the role with the given name are allowed to read this object. | ||
| @param allowed Whether the given role can read this object. | ||
| @param name The name of the role. | ||
| */ | ||
| - (void)setReadAccess:(BOOL)allowed forRoleWithName:(NSString *)name; | ||
|
|
||
| /** | ||
| Get whether users belonging to the role with the given name are allowed to write this object. | ||
| Even if this returns `NO`, the role may still be able to write it if a parent role has write access. | ||
| @param name The name of the role. | ||
| @return `YES` if the role has read access, otherwise `NO`. | ||
| */ | ||
| - (BOOL)getWriteAccessForRoleWithName:(NSString *)name; | ||
|
|
||
| /** | ||
| Set whether users belonging to the role with the given name are allowed to write this object. | ||
| @param allowed Whether the given role can write this object. | ||
| @param name The name of the role. | ||
| */ | ||
| - (void)setWriteAccess:(BOOL)allowed forRoleWithName:(NSString *)name; | ||
|
|
||
| /** | ||
| Get whether users belonging to the given role are allowed to read this object. | ||
| Even if this returns `NO`, the role may still be able to read it if a parent role has read access. | ||
| The role must already be saved on the server and | ||
| it's data must have been fetched in order to use this method. | ||
| @param role The name of the role. | ||
| @return `YES` if the role has read access, otherwise `NO`. | ||
| */ | ||
| - (BOOL)getReadAccessForRole:(PFRole *)role; | ||
|
|
||
| /** | ||
| Set whether users belonging to the given role are allowed to read this object. | ||
| The role must already be saved on the server and | ||
| it's data must have been fetched in order to use this method. | ||
| @param allowed Whether the given role can read this object. | ||
| @param role The role to assign access. | ||
| */ | ||
| - (void)setReadAccess:(BOOL)allowed forRole:(PFRole *)role; | ||
|
|
||
| /** | ||
| Get whether users belonging to the given role are allowed to write this object. | ||
| Even if this returns `NO`, the role may still be able to write it if a parent role has write access. | ||
| The role must already be saved on the server and | ||
| it's data must have been fetched in order to use this method. | ||
| @param role The name of the role. | ||
| @return `YES` if the role has write access, otherwise `NO`. | ||
| */ | ||
| - (BOOL)getWriteAccessForRole:(PFRole *)role; | ||
|
|
||
| /** | ||
| Set whether users belonging to the given role are allowed to write this object. | ||
| The role must already be saved on the server and | ||
| it's data must have been fetched in order to use this method. | ||
| @param allowed Whether the given role can write this object. | ||
| @param role The role to assign access. | ||
| */ | ||
| - (void)setWriteAccess:(BOOL)allowed forRole:(PFRole *)role; | ||
|
|
||
| ///-------------------------------------- | ||
| #pragma mark - Setting Access Defaults | ||
| ///-------------------------------------- | ||
|
|
||
| /** | ||
| Sets a default ACL that will be applied to all instances of `PFObject` when they are created. | ||
| @param acl The ACL to use as a template for all instance of `PFObject` created after this method has been called. | ||
| This value will be copied and used as a template for the creation of new ACLs, so changes to the | ||
| instance after this method has been called will not be reflected in new instance of `PFObject`. | ||
| @param currentUserAccess - If `YES`, the `PFACL` that is applied to newly-created instance of `PFObject` will | ||
| provide read and write access to the `PFUser.+currentUser` at the time of creation. | ||
| - If `NO`, the provided `acl` will be used without modification. | ||
| - If `acl` is `nil`, this value is ignored. | ||
| */ | ||
| + (void)setDefaultACL:(nullable PFACL *)acl withAccessForCurrentUser:(BOOL)currentUserAccess; | ||
|
|
||
| @end | ||
|
|
||
| NS_ASSUME_NONNULL_END |
| @@ -0,0 +1,167 @@ | ||
| /** | ||
| * Copyright (c) 2015-present, Parse, LLC. | ||
| * All rights reserved. | ||
| * | ||
| * This source code is licensed under the BSD-style license found in the | ||
| * LICENSE file in the root directory of this source tree. An additional grant | ||
| * of patent rights can be found in the PATENTS file in the same directory. | ||
| */ | ||
|
|
||
| #import <Foundation/Foundation.h> | ||
|
|
||
| #import <Bolts/BFTask.h> | ||
|
|
||
| #import <Parse/PFConstants.h> | ||
|
|
||
| NS_ASSUME_NONNULL_BEGIN | ||
|
|
||
| /** | ||
| `PFAnalytics` provides an interface to Parse's logging and analytics backend. | ||
| Methods will return immediately and cache the request (+ timestamp) to be | ||
| handled "eventually." That is, the request will be sent immediately if possible | ||
| or the next time a network connection is available. | ||
| */ | ||
| @interface PFAnalytics : NSObject | ||
|
|
||
| ///-------------------------------------- | ||
| #pragma mark - App-Open / Push Analytics | ||
| ///-------------------------------------- | ||
|
|
||
| /** | ||
| Tracks this application being launched. If this happened as the result of the | ||
| user opening a push notification, this method sends along information to | ||
| correlate this open with that push. | ||
| Pass in `nil` to track a standard "application opened" event. | ||
| @param launchOptions The `NSDictionary` indicating the reason the application was | ||
| launched, if any. This value can be found as a parameter to various | ||
| `UIApplicationDelegate` methods, and can be empty or `nil`. | ||
| @return Returns the task encapsulating the work being done. | ||
| */ | ||
| + (BFTask<NSNumber *> *)trackAppOpenedWithLaunchOptions:(nullable NSDictionary *)launchOptions; | ||
|
|
||
| /** | ||
| Tracks this application being launched. | ||
| If this happened as the result of the user opening a push notification, | ||
| this method sends along information to correlate this open with that push. | ||
| Pass in `nil` to track a standard "application opened" event. | ||
| @param launchOptions The dictionary indicating the reason the application was | ||
| launched, if any. This value can be found as a parameter to various | ||
| `UIApplicationDelegate` methods, and can be empty or `nil`. | ||
| @param block The block to execute on server response. | ||
| It should have the following argument signature: `^(BOOL succeeded, NSError *error)` | ||
| */ | ||
| + (void)trackAppOpenedWithLaunchOptionsInBackground:(nullable NSDictionary *)launchOptions | ||
| block:(nullable PFBooleanResultBlock)block; | ||
|
|
||
| /** | ||
| Tracks this application being launched. If this happened as the result of the | ||
| user opening a push notification, this method sends along information to | ||
| correlate this open with that push. | ||
| @param userInfo The Remote Notification payload, if any. This value can be | ||
| found either under `UIApplicationLaunchOptionsRemoteNotificationKey` on `launchOptions`, | ||
| or as a parameter to `application:didReceiveRemoteNotification:`. | ||
| This can be empty or `nil`. | ||
| @return Returns the task encapsulating the work being done. | ||
| */ | ||
| + (BFTask<NSNumber *> *)trackAppOpenedWithRemoteNotificationPayload:(nullable NSDictionary *)userInfo; | ||
|
|
||
| /** | ||
| Tracks this application being launched. If this happened as the result of the | ||
| user opening a push notification, this method sends along information to | ||
| correlate this open with that push. | ||
| @param userInfo The Remote Notification payload, if any. This value can be | ||
| found either under `UIApplicationLaunchOptionsRemoteNotificationKey` on `launchOptions`, | ||
| or as a parameter to `application:didReceiveRemoteNotification:`. This can be empty or `nil`. | ||
| @param block The block to execute on server response. | ||
| It should have the following argument signature: `^(BOOL succeeded, NSError *error)` | ||
| */ | ||
| + (void)trackAppOpenedWithRemoteNotificationPayloadInBackground:(nullable NSDictionary *)userInfo | ||
| block:(nullable PFBooleanResultBlock)block; | ||
|
|
||
| ///-------------------------------------- | ||
| #pragma mark - Custom Analytics | ||
| ///-------------------------------------- | ||
|
|
||
| /** | ||
| Tracks the occurrence of a custom event. | ||
| Parse will store a data point at the time of invocation with the given event name. | ||
| @param name The name of the custom event to report to Parse as having happened. | ||
| @return Returns the task encapsulating the work being done. | ||
| */ | ||
| + (BFTask<NSNumber *> *)trackEvent:(NSString *)name; | ||
|
|
||
| /** | ||
| Tracks the occurrence of a custom event. Parse will store a data point at the | ||
| time of invocation with the given event name. The event will be sent at some | ||
| unspecified time in the future, even if Parse is currently inaccessible. | ||
| @param name The name of the custom event to report to Parse as having happened. | ||
| @param block The block to execute on server response. | ||
| It should have the following argument signature: `^(BOOL succeeded, NSError *error)` | ||
| */ | ||
| + (void)trackEventInBackground:(NSString *)name block:(nullable PFBooleanResultBlock)block; | ||
|
|
||
| /** | ||
| Tracks the occurrence of a custom event with additional dimensions. Parse will | ||
| store a data point at the time of invocation with the given event name. | ||
| Dimensions will allow segmentation of the occurrences of this custom event. | ||
| Keys and values should be NSStrings, and will throw otherwise. | ||
| To track a user signup along with additional metadata, consider the following: | ||
| NSDictionary *dimensions = @{ @"gender": @"m", | ||
| @"source": @"web", | ||
| @"dayType": @"weekend" }; | ||
| [PFAnalytics trackEvent:@"signup" dimensions:dimensions]; | ||
| @warning There is a default limit of 8 dimensions per event tracked. | ||
| @param name The name of the custom event to report to Parse as having happened. | ||
| @param dimensions The `NSDictionary` of information by which to segment this event. | ||
| @return Returns the task encapsulating the work being done. | ||
| */ | ||
| + (BFTask<NSNumber *> *)trackEvent:(NSString *)name | ||
| dimensions:(nullable NSDictionary<NSString *, NSString *> *)dimensions; | ||
|
|
||
| /** | ||
| Tracks the occurrence of a custom event with additional dimensions. Parse will | ||
| store a data point at the time of invocation with the given event name. The | ||
| event will be sent at some unspecified time in the future, even if Parse is currently inaccessible. | ||
| @discussionDimensions will allow segmentation of the occurrences of this custom event. | ||
| Keys and values should be NSStrings, and will throw otherwise. | ||
| To track a user signup along with additional metadata, consider the following: | ||
| NSDictionary *dimensions = @{ @"gender": @"m", | ||
| @"source": @"web", | ||
| @"dayType": @"weekend" }; | ||
| [PFAnalytics trackEvent:@"signup" dimensions:dimensions]; | ||
| There is a default limit of 8 dimensions per event tracked. | ||
| @param name The name of the custom event to report to Parse as having happened. | ||
| @param dimensions The `NSDictionary` of information by which to segment this event. | ||
| @param block The block to execute on server response. | ||
| It should have the following argument signature: `^(BOOL succeeded, NSError *error)` | ||
| */ | ||
| + (void)trackEventInBackground:(NSString *)name | ||
| dimensions:(nullable NSDictionary<NSString *, NSString *> *)dimensions | ||
| block:(nullable PFBooleanResultBlock)block; | ||
|
|
||
| @end | ||
|
|
||
| NS_ASSUME_NONNULL_END |
| @@ -0,0 +1,38 @@ | ||
| /** | ||
| * Copyright (c) 2015-present, Parse, LLC. | ||
| * All rights reserved. | ||
| * | ||
| * This source code is licensed under the BSD-style license found in the | ||
| * LICENSE file in the root directory of this source tree. An additional grant | ||
| * of patent rights can be found in the PATENTS file in the same directory. | ||
| */ | ||
|
|
||
| #import <Parse/PFAnonymousUtils.h> | ||
| #import <Parse/PFConstants.h> | ||
|
|
||
| NS_ASSUME_NONNULL_BEGIN | ||
|
|
||
| /** | ||
| This category lists all methods of `PFAnonymousUtils` that are deprecated and will be removed in the near future. | ||
| */ | ||
| @interface PFAnonymousUtils (Deprecated) | ||
|
|
||
| ///-------------------------------------- | ||
| #pragma mark - Creating an Anonymous User | ||
| ///-------------------------------------- | ||
|
|
||
| /** | ||
| Creates an anonymous user asynchronously and invokes a selector on a target. | ||
| @param target Target object for the selector. | ||
| @param selector The selector that will be called when the asynchronous request is complete. | ||
| It should have the following signature: `(void)callbackWithUser:(PFUser *)user error:(NSError *)error`. | ||
| @deprecated Please use `PFAnonymousUtils.+logInWithBlock:` instead. | ||
| */ | ||
| + (void)logInWithTarget:(nullable id)target | ||
| selector:(nullable SEL)selector PARSE_DEPRECATED("Please use `PFAnonymousUtils.+logInWithBlock:` instead."); | ||
|
|
||
| @end | ||
|
|
||
| NS_ASSUME_NONNULL_END |
| @@ -0,0 +1,73 @@ | ||
| /** | ||
| * Copyright (c) 2015-present, Parse, LLC. | ||
| * All rights reserved. | ||
| * | ||
| * This source code is licensed under the BSD-style license found in the | ||
| * LICENSE file in the root directory of this source tree. An additional grant | ||
| * of patent rights can be found in the PATENTS file in the same directory. | ||
| */ | ||
|
|
||
| #import <Foundation/Foundation.h> | ||
|
|
||
| #import <Bolts/BFTask.h> | ||
|
|
||
| #import <Parse/PFConstants.h> | ||
| #import <Parse/PFUser.h> | ||
|
|
||
| NS_ASSUME_NONNULL_BEGIN | ||
|
|
||
| /** | ||
| Provides utility functions for working with Anonymously logged-in users. | ||
| Anonymous users have some unique characteristics: | ||
| - Anonymous users don't need a user name or password. | ||
| - Once logged out, an anonymous user cannot be recovered. | ||
| - When the current user is anonymous, the following methods can be used to switch | ||
| to a different user or convert the anonymous user into a regular one: | ||
| - signUp converts an anonymous user to a standard user with the given username and password. | ||
| Data associated with the anonymous user is retained. | ||
| - logIn switches users without converting the anonymous user. | ||
| Data associated with the anonymous user will be lost. | ||
| - Service logIn (e.g. Facebook, Twitter) will attempt to convert | ||
| the anonymous user into a standard user by linking it to the service. | ||
| If a user already exists that is linked to the service, it will instead switch to the existing user. | ||
| - Service linking (e.g. Facebook, Twitter) will convert the anonymous user | ||
| into a standard user by linking it to the service. | ||
| */ | ||
| @interface PFAnonymousUtils : NSObject | ||
|
|
||
| ///-------------------------------------- | ||
| #pragma mark - Creating an Anonymous User | ||
| ///-------------------------------------- | ||
|
|
||
| /** | ||
| Creates an anonymous user asynchronously and sets as a result to `BFTask`. | ||
| @return The task, that encapsulates the work being done. | ||
| */ | ||
| + (BFTask<PFUser *> *)logInInBackground; | ||
|
|
||
| /** | ||
| Creates an anonymous user asynchronously and performs a provided block. | ||
| @param block The block to execute when anonymous user creation is complete. | ||
| It should have the following argument signature: `^(PFUser *user, NSError *error)`. | ||
| */ | ||
| + (void)logInWithBlock:(nullable PFUserResultBlock)block; | ||
|
|
||
| ///-------------------------------------- | ||
| #pragma mark - Determining Whether a User is Anonymous | ||
| ///-------------------------------------- | ||
|
|
||
| /** | ||
| Whether the `PFUser` object is logged in anonymously. | ||
| @param user `PFUser` object to check for anonymity. The user must be logged in on this device. | ||
| @return `YES` if the user is anonymous. `NO` if the user is not the current user or is not anonymous. | ||
| */ | ||
| + (BOOL)isLinkedWithUser:(nullable PFUser *)user; | ||
|
|
||
| @end | ||
|
|
||
| NS_ASSUME_NONNULL_END |
| @@ -0,0 +1,40 @@ | ||
| /** | ||
| * Copyright (c) 2015-present, Parse, LLC. | ||
| * All rights reserved. | ||
| * | ||
| * This source code is licensed under the BSD-style license found in the | ||
| * LICENSE file in the root directory of this source tree. An additional grant | ||
| * of patent rights can be found in the PATENTS file in the same directory. | ||
| */ | ||
|
|
||
| #import <Parse/PFCloud.h> | ||
| #import <Parse/PFConstants.h> | ||
|
|
||
| NS_ASSUME_NONNULL_BEGIN | ||
|
|
||
| /** | ||
| This category lists all methods of `PFCloud` that are deprecated and will be removed in the near future. | ||
| */ | ||
| @interface PFCloud (Deprecated) | ||
|
|
||
| /** | ||
| Calls the given cloud function *asynchronously* with the parameters provided | ||
| and then executes the given selector when it is done. | ||
| @param function The function name to call. | ||
| @param parameters The parameters to send to the function. | ||
| @param target The object to call the selector on. | ||
| @param selector The selector to call when the function call finished. | ||
| It should have the following signature: `(void)callbackWithResult:(id)result error:(NSError *)error`. | ||
| Result will be `nil` if error is set and vice versa. | ||
| @deprecated Please use `PFCloud.+callFunctionInBackground:withParameters:` instead. | ||
| */ | ||
| + (void)callFunctionInBackground:(NSString *)function | ||
| withParameters:(nullable NSDictionary *)parameters | ||
| target:(nullable id)target | ||
| selector:(nullable SEL)selector PARSE_DEPRECATED("Please use `PFCloud.+callFunctionInBackground:withParameters:` instead."); | ||
|
|
||
| @end | ||
|
|
||
| NS_ASSUME_NONNULL_END |
| @@ -0,0 +1,47 @@ | ||
| /** | ||
| * Copyright (c) 2015-present, Parse, LLC. | ||
| * All rights reserved. | ||
| * | ||
| * This source code is licensed under the BSD-style license found in the | ||
| * LICENSE file in the root directory of this source tree. An additional grant | ||
| * of patent rights can be found in the PATENTS file in the same directory. | ||
| */ | ||
|
|
||
| #import <Parse/PFCloud.h> | ||
| #import <Parse/PFConstants.h> | ||
|
|
||
| NS_ASSUME_NONNULL_BEGIN | ||
|
|
||
| /** | ||
| This category lists all methods of `PFCloud` class that are synchronous, but have asynchronous counterpart, | ||
| Calling one of these synchronous methods could potentially block the current thread for a large amount of time, | ||
| since it might be fetching from network or saving/loading data from disk. | ||
| */ | ||
| @interface PFCloud (Synchronous) | ||
|
|
||
| /** | ||
| Calls the given cloud function *synchronously* with the parameters provided. | ||
| @param function The function name to call. | ||
| @param parameters The parameters to send to the function. | ||
| @return The response from the cloud function. | ||
| */ | ||
| + (nullable id)callFunction:(NSString *)function withParameters:(nullable NSDictionary *)parameters PF_SWIFT_UNAVAILABLE; | ||
|
|
||
| /** | ||
| Calls the given cloud function *synchronously* with the parameters provided and | ||
| sets the error if there is one. | ||
| @param function The function name to call. | ||
| @param parameters The parameters to send to the function. | ||
| @param error Pointer to an `NSError` that will be set if necessary. | ||
| @return The response from the cloud function. | ||
| This result could be a `NSDictionary`, an `NSArray`, `NSNumber` or `NSString`. | ||
| */ | ||
| + (nullable id)callFunction:(NSString *)function withParameters:(nullable NSDictionary *)parameters error:(NSError **)error; | ||
|
|
||
| @end | ||
|
|
||
| NS_ASSUME_NONNULL_END |
| @@ -0,0 +1,49 @@ | ||
| /** | ||
| * Copyright (c) 2015-present, Parse, LLC. | ||
| * All rights reserved. | ||
| * | ||
| * This source code is licensed under the BSD-style license found in the | ||
| * LICENSE file in the root directory of this source tree. An additional grant | ||
| * of patent rights can be found in the PATENTS file in the same directory. | ||
| */ | ||
|
|
||
| #import <Foundation/Foundation.h> | ||
|
|
||
| #import <Bolts/BFTask.h> | ||
|
|
||
| #import <Parse/PFConstants.h> | ||
|
|
||
| NS_ASSUME_NONNULL_BEGIN | ||
|
|
||
| /** | ||
| The `PFCloud` class provides methods for interacting with Parse Cloud Functions. | ||
| */ | ||
| @interface PFCloud : NSObject | ||
|
|
||
| /** | ||
| Calls the given cloud function *asynchronously* with the parameters provided. | ||
| @param function The function name to call. | ||
| @param parameters The parameters to send to the function. | ||
| @return The task, that encapsulates the work being done. | ||
| */ | ||
| + (BFTask<id> *)callFunctionInBackground:(NSString *)function | ||
| withParameters:(nullable NSDictionary *)parameters; | ||
|
|
||
| /** | ||
| Calls the given cloud function *asynchronously* with the parameters provided | ||
| and executes the given block when it is done. | ||
| @param function The function name to call. | ||
| @param parameters The parameters to send to the function. | ||
| @param block The block to execute when the function call finished. | ||
| It should have the following argument signature: `^(id result, NSError *error)`. | ||
| */ | ||
| + (void)callFunctionInBackground:(NSString *)function | ||
| withParameters:(nullable NSDictionary *)parameters | ||
| block:(nullable PFIdResultBlock)block; | ||
|
|
||
| @end | ||
|
|
||
| NS_ASSUME_NONNULL_END |
| @@ -0,0 +1,44 @@ | ||
| /** | ||
| * Copyright (c) 2015-present, Parse, LLC. | ||
| * All rights reserved. | ||
| * | ||
| * This source code is licensed under the BSD-style license found in the | ||
| * LICENSE file in the root directory of this source tree. An additional grant | ||
| * of patent rights can be found in the PATENTS file in the same directory. | ||
| */ | ||
|
|
||
| #import <Parse/PFConfig.h> | ||
| #import <Parse/PFConstants.h> | ||
|
|
||
| NS_ASSUME_NONNULL_BEGIN | ||
|
|
||
| /** | ||
| This category lists all methods of `PFConfig` class that are synchronous, but have asynchronous counterpart, | ||
| Calling one of these synchronous methods could potentially block the current thread for a large amount of time, | ||
| since it might be fetching from network or saving/loading data from disk. | ||
| */ | ||
| @interface PFConfig (Synchronous) | ||
|
|
||
| ///-------------------------------------- | ||
| #pragma mark - Retrieving Config | ||
| ///-------------------------------------- | ||
|
|
||
| /** | ||
| Gets the `PFConfig` object *synchronously* from the server. | ||
| @return Instance of `PFConfig` if the operation succeeded, otherwise `nil`. | ||
| */ | ||
| + (nullable PFConfig *)getConfig PF_SWIFT_UNAVAILABLE; | ||
|
|
||
| /** | ||
| Gets the `PFConfig` object *synchronously* from the server and sets an error if it occurs. | ||
| @param error Pointer to an `NSError` that will be set if necessary. | ||
| @return Instance of PFConfig if the operation succeeded, otherwise `nil`. | ||
| */ | ||
| + (nullable PFConfig *)getConfig:(NSError **)error; | ||
|
|
||
| @end | ||
|
|
||
| NS_ASSUME_NONNULL_END |
| @@ -0,0 +1,89 @@ | ||
| /** | ||
| * Copyright (c) 2015-present, Parse, LLC. | ||
| * All rights reserved. | ||
| * | ||
| * This source code is licensed under the BSD-style license found in the | ||
| * LICENSE file in the root directory of this source tree. An additional grant | ||
| * of patent rights can be found in the PATENTS file in the same directory. | ||
| */ | ||
|
|
||
| #import <Foundation/Foundation.h> | ||
|
|
||
| #import <Bolts/BFTask.h> | ||
|
|
||
| #import <Parse/PFConstants.h> | ||
|
|
||
| NS_ASSUME_NONNULL_BEGIN | ||
|
|
||
| @class PFConfig; | ||
|
|
||
| typedef void(^PFConfigResultBlock)(PFConfig *_Nullable config, NSError *_Nullable error); | ||
|
|
||
| /** | ||
| `PFConfig` is a representation of the remote configuration object. | ||
| It enables you to add things like feature gating, a/b testing or simple "Message of the day". | ||
| */ | ||
| @interface PFConfig : NSObject | ||
|
|
||
| ///-------------------------------------- | ||
| #pragma mark - Current Config | ||
| ///-------------------------------------- | ||
|
|
||
| /** | ||
| Returns the most recently fetched config. | ||
| If there was no config fetched - this method will return an empty instance of `PFConfig`. | ||
| @return Current, last fetched instance of PFConfig. | ||
| */ | ||
| + (PFConfig *)currentConfig; | ||
|
|
||
| ///-------------------------------------- | ||
| #pragma mark - Retrieving Config | ||
| ///-------------------------------------- | ||
|
|
||
| /** | ||
| Gets the `PFConfig` *asynchronously* and sets it as a result of a task. | ||
| @return The task, that encapsulates the work being done. | ||
| */ | ||
| + (BFTask<PFConfig *> *)getConfigInBackground; | ||
|
|
||
| /** | ||
| Gets the `PFConfig` *asynchronously* and executes the given callback block. | ||
| @param block The block to execute. | ||
| It should have the following argument signature: `^(PFConfig *config, NSError *error)`. | ||
| */ | ||
| + (void)getConfigInBackgroundWithBlock:(nullable PFConfigResultBlock)block; | ||
|
|
||
| ///-------------------------------------- | ||
| #pragma mark - Parameters | ||
| ///-------------------------------------- | ||
|
|
||
| /** | ||
| Returns the object associated with a given key. | ||
| @param key The key for which to return the corresponding configuration value. | ||
| @return The value associated with `key`, or `nil` if there is no such value. | ||
| */ | ||
| - (nullable id)objectForKey:(NSString *)key; | ||
|
|
||
| /** | ||
| Returns the object associated with a given key. | ||
| This method enables usage of literal syntax on `PFConfig`. | ||
| E.g. `NSString *value = config[@"key"];` | ||
| @see objectForKey: | ||
| @param keyedSubscript The keyed subscript for which to return the corresponding configuration value. | ||
| @return The value associated with `key`, or `nil` if there is no such value. | ||
| */ | ||
| - (nullable id)objectForKeyedSubscript:(NSString *)keyedSubscript; | ||
|
|
||
| @end | ||
|
|
||
| NS_ASSUME_NONNULL_END |
| @@ -0,0 +1,57 @@ | ||
| /** | ||
| * Copyright (c) 2015-present, Parse, LLC. | ||
| * All rights reserved. | ||
| * | ||
| * This source code is licensed under the BSD-style license found in the | ||
| * LICENSE file in the root directory of this source tree. An additional grant | ||
| * of patent rights can be found in the PATENTS file in the same directory. | ||
| */ | ||
|
|
||
| #import <Parse/PFConstants.h> | ||
| #import <Parse/PFFile.h> | ||
|
|
||
| NS_ASSUME_NONNULL_BEGIN | ||
|
|
||
| /** | ||
| This category lists all methods of `PFFile` that are deprecated and will be removed in the near future. | ||
| */ | ||
| @interface PFFile (Deprecated) | ||
|
|
||
| ///-------------------------------------- | ||
| #pragma mark - Saving Files | ||
| ///-------------------------------------- | ||
|
|
||
| /** | ||
| Saves the file *asynchronously* and invokes the given selector on a target. | ||
| @param target The object to call selector on. | ||
| @param selector The selector to call. | ||
| It should have the following signature: `(void)callbackWithResult:(NSNumber *)result error:(NSError *)error`. | ||
| `error` will be `nil` on success and set if there was an error. | ||
| `[result boolValue]` will tell you whether the call succeeded or not. | ||
| @deprecated Please use `PFFile.-saveInBackgroundWithBlock:` instead. | ||
| */ | ||
| - (void)saveInBackgroundWithTarget:(nullable id)target | ||
| selector:(nullable SEL)selector PARSE_DEPRECATED("Please use `PFFile.-saveInBackgroundWithBlock:` instead."); | ||
|
|
||
| ///-------------------------------------- | ||
| #pragma mark - Getting Files | ||
| ///-------------------------------------- | ||
|
|
||
| /** | ||
| *Asynchronously* gets the data from cache if available or fetches its contents from the network. | ||
| @param target The object to call selector on. | ||
| @param selector The selector to call. | ||
| It should have the following signature: `(void)callbackWithResult:(NSData *)result error:(NSError *)error`. | ||
| `error` will be `nil` on success and set if there was an error. | ||
| @deprecated Please use `PFFile.-getDataInBackgroundWithBlock:` instead. | ||
| */ | ||
| - (void)getDataInBackgroundWithTarget:(nullable id)target | ||
| selector:(nullable SEL)selector PARSE_DEPRECATED("Please use `PFFile.-getDataInBackgroundWithBlock:` instead."); | ||
|
|
||
| @end | ||
|
|
||
| NS_ASSUME_NONNULL_END |
| @@ -0,0 +1,89 @@ | ||
| /** | ||
| * Copyright (c) 2015-present, Parse, LLC. | ||
| * All rights reserved. | ||
| * | ||
| * This source code is licensed under the BSD-style license found in the | ||
| * LICENSE file in the root directory of this source tree. An additional grant | ||
| * of patent rights can be found in the PATENTS file in the same directory. | ||
| */ | ||
|
|
||
| #import <Parse/PFConstants.h> | ||
| #import <Parse/PFFile.h> | ||
|
|
||
| NS_ASSUME_NONNULL_BEGIN | ||
|
|
||
| /** | ||
| This category lists all methods of `PFFile` class that are synchronous, but have asynchronous counterpart, | ||
| Calling one of these synchronous methods could potentially block the current thread for a large amount of time, | ||
| since it might be fetching from network or saving/loading data from disk. | ||
| */ | ||
| @interface PFFile (Synchronous) | ||
|
|
||
| ///-------------------------------------- | ||
| #pragma mark - Storing Data with Parse | ||
| ///-------------------------------------- | ||
|
|
||
| /** | ||
| Saves the file *synchronously*. | ||
| @return Returns whether the save succeeded. | ||
| */ | ||
| - (BOOL)save PF_SWIFT_UNAVAILABLE; | ||
|
|
||
| /** | ||
| Saves the file *synchronously* and sets an error if it occurs. | ||
| @param error Pointer to an `NSError` that will be set if necessary. | ||
| @return Returns whether the save succeeded. | ||
| */ | ||
| - (BOOL)save:(NSError **)error; | ||
|
|
||
| ///-------------------------------------- | ||
| #pragma mark - Getting Data from Parse | ||
| ///-------------------------------------- | ||
|
|
||
| /** | ||
| Whether the data is available in memory or needs to be downloaded. | ||
| */ | ||
| @property (nonatomic, assign, readonly, getter=isDataAvailable) BOOL dataAvailable; | ||
|
|
||
| /** | ||
| *Synchronously* gets the data from cache if available or fetches its contents from the network. | ||
| @return The `NSData` object containing file data. Returns `nil` if there was an error in fetching. | ||
| */ | ||
| - (nullable NSData *)getData PF_SWIFT_UNAVAILABLE; | ||
|
|
||
| /** | ||
| *Synchronously* gets the data from cache if available or fetches its contents from the network. | ||
| Sets an error if it occurs. | ||
| @param error Pointer to an `NSError` that will be set if necessary. | ||
| @return The `NSData` object containing file data. Returns `nil` if there was an error in fetching. | ||
| */ | ||
| - (nullable NSData *)getData:(NSError **)error; | ||
|
|
||
| /** | ||
| This method is like `-getData` but avoids ever holding the entire `PFFile` contents in memory at once. | ||
| This can help applications with many large files avoid memory warnings. | ||
| @return A stream containing the data. Returns `nil` if there was an error in fetching. | ||
| */ | ||
| - (nullable NSInputStream *)getDataStream PF_SWIFT_UNAVAILABLE; | ||
|
|
||
| /** | ||
| This method is like `-getData` but avoids ever holding the entire `PFFile` contents in memory at once. | ||
| @param error Pointer to an `NSError` that will be set if necessary. | ||
| @return A stream containing the data. Returns nil if there was an error in | ||
| fetching. | ||
| */ | ||
| - (nullable NSInputStream *)getDataStream:(NSError **)error; | ||
|
|
||
| @end | ||
|
|
||
| NS_ASSUME_NONNULL_END |
| @@ -0,0 +1,371 @@ | ||
| /** | ||
| * Copyright (c) 2015-present, Parse, LLC. | ||
| * All rights reserved. | ||
| * | ||
| * This source code is licensed under the BSD-style license found in the | ||
| * LICENSE file in the root directory of this source tree. An additional grant | ||
| * of patent rights can be found in the PATENTS file in the same directory. | ||
| */ | ||
|
|
||
| #import <Foundation/Foundation.h> | ||
|
|
||
| #import <Bolts/BFTask.h> | ||
|
|
||
| #import <Parse/PFConstants.h> | ||
|
|
||
| NS_ASSUME_NONNULL_BEGIN | ||
|
|
||
| /** | ||
| `PFFile` representes a file of binary data stored on the Parse servers. | ||
| This can be a image, video, or anything else that an application needs to reference in a non-relational way. | ||
| */ | ||
| @interface PFFile : NSObject | ||
|
|
||
| ///-------------------------------------- | ||
| #pragma mark - Creating a PFFile | ||
| ///-------------------------------------- | ||
|
|
||
| - (instancetype)init NS_UNAVAILABLE; | ||
| + (instancetype)new NS_UNAVAILABLE; | ||
|
|
||
| /** | ||
| Creates a file with given data. A name will be assigned to it by the server. | ||
| @param data The contents of the new `PFFile`. | ||
| @return A new `PFFile`. | ||
| */ | ||
| + (nullable instancetype)fileWithData:(NSData *)data; | ||
|
|
||
| /** | ||
| Creates a file with given data and name. | ||
| @param name The name of the new PFFile. The file name must begin with and | ||
| alphanumeric character, and consist of alphanumeric characters, periods, | ||
| spaces, underscores, or dashes. | ||
| @param data The contents of the new `PFFile`. | ||
| @return A new `PFFile` object. | ||
| */ | ||
| + (nullable instancetype)fileWithName:(nullable NSString *)name data:(NSData *)data; | ||
|
|
||
| /** | ||
| Creates a file with the contents of another file. | ||
| @warning This method raises an exception if the file at path is not accessible | ||
| or if there is not enough disk space left. | ||
| @param name The name of the new `PFFile`. The file name must begin with and alphanumeric character, | ||
| and consist of alphanumeric characters, periods, spaces, underscores, or dashes. | ||
| @param path The path to the file that will be uploaded to Parse. | ||
| @return A new `PFFile` instance. | ||
| */ | ||
| + (nullable instancetype)fileWithName:(nullable NSString *)name | ||
| contentsAtPath:(NSString *)path PF_SWIFT_UNAVAILABLE; | ||
|
|
||
| /** | ||
| Creates a file with the contents of another file. | ||
| @param name The name of the new `PFFile`. The file name must begin with and alphanumeric character, | ||
| and consist of alphanumeric characters, periods, spaces, underscores, or dashes. | ||
| @param path The path to the file that will be uploaded to Parse. | ||
| @param error On input, a pointer to an error object. | ||
| If an error occurs, this pointer is set to an actual error object containing the error information. | ||
| You may specify `nil` for this parameter if you do not want the error information. | ||
| @return A new `PFFile` instance or `nil` if the error occured. | ||
| */ | ||
| + (nullable instancetype)fileWithName:(nullable NSString *)name | ||
| contentsAtPath:(NSString *)path | ||
| error:(NSError **)error; | ||
|
|
||
| /** | ||
| Creates a file with given data, name and content type. | ||
| @warning This method raises an exception if the data supplied is not accessible or could not be saved. | ||
| @param name The name of the new `PFFile`. The file name must begin with and alphanumeric character, | ||
| and consist of alphanumeric characters, periods, spaces, underscores, or dashes. | ||
| @param data The contents of the new `PFFile`. | ||
| @param contentType Represents MIME type of the data. | ||
| @return A new `PFFile` instance. | ||
| */ | ||
| + (nullable instancetype)fileWithName:(nullable NSString *)name | ||
| data:(NSData *)data | ||
| contentType:(nullable NSString *)contentType PF_SWIFT_UNAVAILABLE; | ||
|
|
||
| /** | ||
| Creates a file with given data, name and content type. | ||
| @param name The name of the new `PFFile`. The file name must begin with and alphanumeric character, | ||
| and consist of alphanumeric characters, periods, spaces, underscores, or dashes. | ||
| @param data The contents of the new `PFFile`. | ||
| @param contentType Represents MIME type of the data. | ||
| @param error On input, a pointer to an error object. | ||
| If an error occurs, this pointer is set to an actual error object containing the error information. | ||
| You may specify `nil` for this parameter if you do not want the error information. | ||
| @return A new `PFFile` instance or `nil` if the error occured. | ||
| */ | ||
| + (nullable instancetype)fileWithName:(nullable NSString *)name | ||
| data:(NSData *)data | ||
| contentType:(nullable NSString *)contentType | ||
| error:(NSError **)error; | ||
|
|
||
| /** | ||
| Creates a file with given data and content type. | ||
| @param data The contents of the new `PFFile`. | ||
| @param contentType Represents MIME type of the data. | ||
| @return A new `PFFile` object. | ||
| */ | ||
| + (instancetype)fileWithData:(NSData *)data contentType:(nullable NSString *)contentType; | ||
|
|
||
| ///-------------------------------------- | ||
| #pragma mark - File Properties | ||
| ///-------------------------------------- | ||
|
|
||
| /** | ||
| The name of the file. | ||
| Before the file is saved, this is the filename given by | ||
| the user. After the file is saved, that name gets prefixed with a unique | ||
| identifier. | ||
| */ | ||
| @property (nonatomic, copy, readonly) NSString *name; | ||
|
|
||
| /** | ||
| The url of the file. | ||
| */ | ||
| @property (nullable, nonatomic, copy, readonly) NSString *url; | ||
|
|
||
| /** | ||
| Whether the file has been uploaded for the first time. | ||
| */ | ||
| @property (nonatomic, assign, readonly, getter=isDirty) BOOL dirty; | ||
|
|
||
| ///-------------------------------------- | ||
| #pragma mark - Storing Data with Parse | ||
| ///-------------------------------------- | ||
|
|
||
| /** | ||
| Saves the file *asynchronously*. | ||
| @return The task, that encapsulates the work being done. | ||
| */ | ||
| - (BFTask<NSNumber *> *)saveInBackground; | ||
|
|
||
| /** | ||
| Saves the file *asynchronously* | ||
| @param progressBlock The block should have the following argument signature: `^(int percentDone)` | ||
| @return The task, that encapsulates the work being done. | ||
| */ | ||
| - (BFTask<NSNumber *> *)saveInBackgroundWithProgressBlock:(nullable PFProgressBlock)progressBlock; | ||
|
|
||
| /** | ||
| Saves the file *asynchronously* and executes the given block. | ||
| @param block The block should have the following argument signature: `^(BOOL succeeded, NSError *error)`. | ||
| */ | ||
| - (void)saveInBackgroundWithBlock:(nullable PFBooleanResultBlock)block; | ||
|
|
||
| /** | ||
| Saves the file *asynchronously* and executes the given block. | ||
| This method will execute the progressBlock periodically with the percent progress. | ||
| `progressBlock` will get called with `100` before `resultBlock` is called. | ||
| @param block The block should have the following argument signature: `^(BOOL succeeded, NSError *error)` | ||
| @param progressBlock The block should have the following argument signature: `^(int percentDone)` | ||
| */ | ||
| - (void)saveInBackgroundWithBlock:(nullable PFBooleanResultBlock)block | ||
| progressBlock:(nullable PFProgressBlock)progressBlock; | ||
|
|
||
| ///-------------------------------------- | ||
| #pragma mark - Getting Data from Parse | ||
| ///-------------------------------------- | ||
|
|
||
| /** | ||
| Whether the data is available in memory or needs to be downloaded. | ||
| */ | ||
| @property (nonatomic, assign, readonly, getter=isDataAvailable) BOOL dataAvailable; | ||
|
|
||
| /** | ||
| This method is like `-getData` but it fetches asynchronously to avoid blocking the current thread. | ||
| @see getData | ||
| @return The task, that encapsulates the work being done. | ||
| */ | ||
| - (BFTask<NSData *> *)getDataInBackground; | ||
|
|
||
| /** | ||
| This method is like `-getData` but it fetches asynchronously to avoid blocking the current thread. | ||
| This can help applications with many large files avoid memory warnings. | ||
| @see getData | ||
| @param progressBlock The block should have the following argument signature: ^(int percentDone) | ||
| @return The task, that encapsulates the work being done. | ||
| */ | ||
| - (BFTask<NSData *> *)getDataInBackgroundWithProgressBlock:(nullable PFProgressBlock)progressBlock; | ||
|
|
||
| /** | ||
| This method is like `-getDataInBackground` but avoids ever holding the entire `PFFile` contents in memory at once. | ||
| This can help applications with many large files avoid memory warnings. | ||
| @return The task, that encapsulates the work being done. | ||
| */ | ||
| - (BFTask<NSInputStream *> *)getDataStreamInBackground; | ||
|
|
||
| /** | ||
| This method is like `-getDataStreamInBackground`, but yields a live-updating stream. | ||
| Instead of `-getDataStream`, which yields a stream that can be read from only after the request has | ||
| completed, this method gives you a stream directly written to by the HTTP session. As this stream is not pre-buffered, | ||
| it is strongly advised to use the `NSStreamDelegate` methods, in combination with a run loop, to consume the data in | ||
| the stream, to do proper async file downloading. | ||
| @note You MUST open this stream before reading from it. | ||
| @note Do NOT call `waitUntilFinished` on this task from the main thread. It may result in a deadlock. | ||
| @return A task that produces a *live* stream that is being written to with the data from the server. | ||
| */ | ||
| - (BFTask<NSInputStream *> *)getDataDownloadStreamInBackground; | ||
|
|
||
| /** | ||
| This method is like `-getDataInBackground` but avoids | ||
| ever holding the entire `PFFile` contents in memory at once. | ||
| This can help applications with many large files avoid memory warnings. | ||
| @param progressBlock The block should have the following argument signature: ^(int percentDone) | ||
| @return The task, that encapsulates the work being done. | ||
| */ | ||
| - (BFTask<NSInputStream *> *)getDataStreamInBackgroundWithProgressBlock:(nullable PFProgressBlock)progressBlock; | ||
|
|
||
| /** | ||
| This method is like `-getDataStreamInBackgroundWithProgressBlock:`, but yields a live-updating stream. | ||
| Instead of `-getDataStream`, which yields a stream that can be read from only after the request has | ||
| completed, this method gives you a stream directly written to by the HTTP session. As this stream is not pre-buffered, | ||
| it is strongly advised to use the `NSStreamDelegate` methods, in combination with a run loop, to consume the data in | ||
| the stream, to do proper async file downloading. | ||
| @note You MUST open this stream before reading from it. | ||
| @note Do NOT call `waitUntilFinished` on this task from the main thread. It may result in a deadlock. | ||
| @param progressBlock The block should have the following argument signature: `^(int percentDone)` | ||
| @return A task that produces a *live* stream that is being written to with the data from the server. | ||
| */ | ||
| - (BFTask<NSInputStream *> *)getDataDownloadStreamInBackgroundWithProgressBlock:(nullable PFProgressBlock)progressBlock; | ||
|
|
||
| /** | ||
| *Asynchronously* gets the data from cache if available or fetches its contents from the network. | ||
| @param block The block should have the following argument signature: `^(NSData *result, NSError *error)` | ||
| */ | ||
| - (void)getDataInBackgroundWithBlock:(nullable PFDataResultBlock)block; | ||
|
|
||
| /** | ||
| This method is like `-getDataInBackgroundWithBlock:` but avoids ever holding the entire `PFFile` contents in memory at once. | ||
| This can help applications with many large files avoid memory warnings. | ||
| @param block The block should have the following argument signature: `(NSInputStream *result, NSError *error)` | ||
| */ | ||
| - (void)getDataStreamInBackgroundWithBlock:(nullable PFDataStreamResultBlock)block; | ||
|
|
||
| /** | ||
| *Asynchronously* gets the data from cache if available or fetches its contents from the network. | ||
| This method will execute the progressBlock periodically with the percent progress. | ||
| `progressBlock` will get called with `100` before `resultBlock` is called. | ||
| @param resultBlock The block should have the following argument signature: ^(NSData *result, NSError *error) | ||
| @param progressBlock The block should have the following argument signature: ^(int percentDone) | ||
| */ | ||
| - (void)getDataInBackgroundWithBlock:(nullable PFDataResultBlock)resultBlock | ||
| progressBlock:(nullable PFProgressBlock)progressBlock; | ||
|
|
||
| /** | ||
| This method is like `-getDataInBackgroundWithBlock:progressBlock:` but avoids | ||
| ever holding the entire `PFFile` contents in memory at once. | ||
| This can help applications with many large files avoid memory warnings. | ||
| @param resultBlock The block should have the following argument signature: `^(NSInputStream *result, NSError *error)`. | ||
| @param progressBlock The block should have the following argument signature: `^(int percentDone)`. | ||
| */ | ||
| - (void)getDataStreamInBackgroundWithBlock:(nullable PFDataStreamResultBlock)resultBlock | ||
| progressBlock:(nullable PFProgressBlock)progressBlock; | ||
|
|
||
| /** | ||
| *Asynchronously* gets the file path for file from cache if available or fetches its contents from the network. | ||
| @note The file path may change between versions of SDK. | ||
| @note If you overwrite the contents of the file at returned path it will persist those change | ||
| until the file cache is cleared. | ||
| @return The task, with the result set to `NSString` representation of a file path. | ||
| */ | ||
| - (BFTask<NSString *> *)getFilePathInBackground; | ||
|
|
||
| /** | ||
| *Asynchronously* gets the file path for file from cache if available or fetches its contents from the network. | ||
| @note The file path may change between versions of SDK. | ||
| @note If you overwrite the contents of the file at returned path it will persist those change | ||
| until the file cache is cleared. | ||
| @param progressBlock The block should have the following argument signature: `^(int percentDone)`. | ||
| @return The task, with the result set to `NSString` representation of a file path. | ||
| */ | ||
| - (BFTask<NSString *> *)getFilePathInBackgroundWithProgressBlock:(nullable PFProgressBlock)progressBlock; | ||
|
|
||
| /** | ||
| *Asynchronously* gets the file path for file from cache if available or fetches its contents from the network. | ||
| @note The file path may change between versions of SDK. | ||
| @note If you overwrite the contents of the file at returned path it will persist those change | ||
| until the file cache is cleared. | ||
| @param block The block should have the following argument signature: `^(NSString *filePath, NSError *error)`. | ||
| */ | ||
| - (void)getFilePathInBackgroundWithBlock:(nullable PFFilePathResultBlock)block; | ||
|
|
||
| /** | ||
| *Asynchronously* gets the file path for file from cache if available or fetches its contents from the network. | ||
| @note The file path may change between versions of SDK. | ||
| @note If you overwrite the contents of the file at returned path it will persist those change | ||
| until the file cache is cleared. | ||
| @param block The block should have the following argument signature: `^(NSString *filePath, NSError *error)`. | ||
| @param progressBlock The block should have the following argument signature: `^(int percentDone)`. | ||
| */ | ||
| - (void)getFilePathInBackgroundWithBlock:(nullable PFFilePathResultBlock)block | ||
| progressBlock:(nullable PFProgressBlock)progressBlock; | ||
|
|
||
| ///-------------------------------------- | ||
| #pragma mark - Interrupting a Transfer | ||
| ///-------------------------------------- | ||
|
|
||
| /** | ||
| Cancels the current request (upload or download of file). | ||
| */ | ||
| - (void)cancel; | ||
|
|
||
| @end | ||
|
|
||
| NS_ASSUME_NONNULL_END |
| @@ -0,0 +1,112 @@ | ||
| /** | ||
| * Copyright (c) 2015-present, Parse, LLC. | ||
| * All rights reserved. | ||
| * | ||
| * This source code is licensed under the BSD-style license found in the | ||
| * LICENSE file in the root directory of this source tree. An additional grant | ||
| * of patent rights can be found in the PATENTS file in the same directory. | ||
| */ | ||
|
|
||
| #import <CoreLocation/CoreLocation.h> | ||
| #import <Foundation/Foundation.h> | ||
|
|
||
| NS_ASSUME_NONNULL_BEGIN | ||
|
|
||
| @class PFGeoPoint; | ||
|
|
||
| typedef void(^PFGeoPointResultBlock)(PFGeoPoint *_Nullable geoPoint, NSError *_Nullable error); | ||
|
|
||
| /** | ||
| `PFGeoPoint` may be used to embed a latitude / longitude point as the value for a key in a `PFObject`. | ||
| It could be used to perform queries in a geospatial manner using `PFQuery.-whereKey:nearGeoPoint:`. | ||
| Currently, instances of `PFObject` may only have one key associated with a `PFGeoPoint` type. | ||
| */ | ||
| @interface PFGeoPoint : NSObject <NSCopying, NSCoding> | ||
|
|
||
| ///-------------------------------------- | ||
| #pragma mark - Creating a Geo Point | ||
| ///-------------------------------------- | ||
|
|
||
| /** | ||
| Create a PFGeoPoint object. Latitude and longitude are set to `0.0`. | ||
| @return Returns a new `PFGeoPoint`. | ||
| */ | ||
| + (instancetype)geoPoint; | ||
|
|
||
| /** | ||
| Creates a new `PFGeoPoint` object for the given `CLLocation`, set to the location's coordinates. | ||
| @param location Instace of `CLLocation`, with set latitude and longitude. | ||
| @return Returns a new PFGeoPoint at specified location. | ||
| */ | ||
| + (instancetype)geoPointWithLocation:(nullable CLLocation *)location; | ||
|
|
||
| /** | ||
| Create a new `PFGeoPoint` object with the specified latitude and longitude. | ||
| @param latitude Latitude of point in degrees. | ||
| @param longitude Longitude of point in degrees. | ||
| @return New point object with specified latitude and longitude. | ||
| */ | ||
| + (instancetype)geoPointWithLatitude:(double)latitude longitude:(double)longitude; | ||
|
|
||
| /** | ||
| Fetches the current device location and executes a block with a new `PFGeoPoint` object. | ||
| @param resultBlock A block which takes the newly created `PFGeoPoint` as an argument. | ||
| It should have the following argument signature: `^(PFGeoPoint *geoPoint, NSError *error)` | ||
| */ | ||
| + (void)geoPointForCurrentLocationInBackground:(nullable PFGeoPointResultBlock)resultBlock; | ||
|
|
||
| ///-------------------------------------- | ||
| #pragma mark - Controlling Position | ||
| ///-------------------------------------- | ||
|
|
||
| /** | ||
| Latitude of point in degrees. Valid range is from `-90.0` to `90.0`. | ||
| */ | ||
| @property (nonatomic, assign) double latitude; | ||
|
|
||
| /** | ||
| Longitude of point in degrees. Valid range is from `-180.0` to `180.0`. | ||
| */ | ||
| @property (nonatomic, assign) double longitude; | ||
|
|
||
| ///-------------------------------------- | ||
| #pragma mark - Calculating Distance | ||
| ///-------------------------------------- | ||
|
|
||
| /** | ||
| Get distance in radians from this point to specified point. | ||
| @param point `PFGeoPoint` that represents the location of other point. | ||
| @return Distance in radians between the receiver and `point`. | ||
| */ | ||
| - (double)distanceInRadiansTo:(nullable PFGeoPoint *)point; | ||
|
|
||
| /** | ||
| Get distance in miles from this point to specified point. | ||
| @param point `PFGeoPoint` that represents the location of other point. | ||
| @return Distance in miles between the receiver and `point`. | ||
| */ | ||
| - (double)distanceInMilesTo:(nullable PFGeoPoint *)point; | ||
|
|
||
| /** | ||
| Get distance in kilometers from this point to specified point. | ||
| @param point `PFGeoPoint` that represents the location of other point. | ||
| @return Distance in kilometers between the receiver and `point`. | ||
| */ | ||
| - (double)distanceInKilometersTo:(nullable PFGeoPoint *)point; | ||
|
|
||
| @end | ||
|
|
||
| NS_ASSUME_NONNULL_END |
| @@ -0,0 +1,115 @@ | ||
| /** | ||
| * Copyright (c) 2015-present, Parse, LLC. | ||
| * All rights reserved. | ||
| * | ||
| * This source code is licensed under the BSD-style license found in the | ||
| * LICENSE file in the root directory of this source tree. An additional grant | ||
| * of patent rights can be found in the PATENTS file in the same directory. | ||
| */ | ||
|
|
||
| #import <Foundation/Foundation.h> | ||
|
|
||
| #import <Parse/PFObject.h> | ||
| #import <Parse/PFSubclassing.h> | ||
|
|
||
| PF_TV_UNAVAILABLE_WARNING | ||
| PF_WATCH_UNAVAILABLE_WARNING | ||
|
|
||
| NS_ASSUME_NONNULL_BEGIN | ||
|
|
||
| /** | ||
| A Parse Framework Installation Object that is a local representation of an | ||
| installation persisted to the Parse cloud. This class is a subclass of a | ||
| `PFObject`, and retains the same functionality of a PFObject, but also extends | ||
| it with installation-specific fields and related immutability and validity | ||
| checks. | ||
| A valid `PFInstallation` can only be instantiated via | ||
| `+currentInstallation` because the required identifier fields | ||
| are readonly. The `timeZone` and `badge` fields are also readonly properties which | ||
| are automatically updated to match the device's time zone and application badge | ||
| when the `PFInstallation` is saved, thus these fields might not reflect the | ||
| latest device state if the installation has not recently been saved. | ||
| `PFInstallation` objects which have a valid `deviceToken` and are saved to | ||
| the Parse cloud can be used to target push notifications. | ||
| */ | ||
|
|
||
| PF_TV_UNAVAILABLE PF_WATCH_UNAVAILABLE @interface PFInstallation : PFObject<PFSubclassing> | ||
|
|
||
| ///-------------------------------------- | ||
| #pragma mark - Accessing the Current Installation | ||
| ///-------------------------------------- | ||
|
|
||
| /** | ||
| Gets the currently-running installation from disk and returns an instance of it. | ||
| If this installation is not stored on disk, returns a `PFInstallation` | ||
| with `deviceType` and `installationId` fields set to those of the | ||
| current installation. | ||
| @result Returns a `PFInstallation` that represents the currently-running installation. | ||
| */ | ||
| + (instancetype)currentInstallation; | ||
|
|
||
| ///-------------------------------------- | ||
| #pragma mark - Installation Properties | ||
| ///-------------------------------------- | ||
|
|
||
| /** | ||
| The device type for the `PFInstallation`. | ||
| */ | ||
| @property (nonatomic, copy, readonly) NSString *deviceType; | ||
|
|
||
| /** | ||
| The installationId for the `PFInstallation`. | ||
| */ | ||
| @property (nonatomic, copy, readonly) NSString *installationId; | ||
|
|
||
| /** | ||
| The device token for the `PFInstallation`. | ||
| */ | ||
| @property (nullable, nonatomic, copy) NSString *deviceToken; | ||
|
|
||
| /** | ||
| The badge for the `PFInstallation`. | ||
| */ | ||
| @property (nonatomic, assign) NSInteger badge; | ||
|
|
||
| /** | ||
| The name of the time zone for the `PFInstallation`. | ||
| */ | ||
| @property (nullable, nonatomic, copy, readonly) NSString *timeZone; | ||
|
|
||
| /** | ||
| The channels for the `PFInstallation`. | ||
| */ | ||
| @property (nullable, nonatomic, copy) NSArray<NSString *> *channels; | ||
|
|
||
| /** | ||
| Sets the device token string property from an `NSData`-encoded token. | ||
| @param deviceTokenData A token that identifies the device. | ||
| */ | ||
| - (void)setDeviceTokenFromData:(nullable NSData *)deviceTokenData; | ||
|
|
||
| ///-------------------------------------- | ||
| #pragma mark - Querying for Installations | ||
| ///-------------------------------------- | ||
|
|
||
| /** | ||
| Creates a `PFQuery` for `PFInstallation` objects. | ||
| Only the following types of queries are allowed for installations: | ||
| - `[query getObjectWithId:<value>]` | ||
| - `[query whereKey:@"installationId" equalTo:<value>]` | ||
| - `[query whereKey:@"installationId" matchesKey:<key in query> inQuery:<query>]` | ||
| You can add additional query conditions, but one of the above must appear as a top-level `AND` clause in the query. | ||
| */ | ||
| + (nullable PFQuery *)query; | ||
|
|
||
| @end | ||
|
|
||
| NS_ASSUME_NONNULL_END |