Abhishek Banthia
9 years ago
51 changed files with 6806 additions and 3 deletions
Binary file not shown.
@ -0,0 +1 @@
|
||||
Versions/Current/Resources |
Binary file not shown.
@ -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,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,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.0" |
@ -0,0 +1,6 @@
|
||||
framework module Bolts { |
||||
umbrella header "Bolts.h" |
||||
|
||||
export * |
||||
module * { export * } |
||||
} |
@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
||||
<plist version="1.0"> |
||||
<dict> |
||||
<key>BuildMachineOSBuild</key> |
||||
<string>15C50</string> |
||||
<key>CFBundleDevelopmentRegion</key> |
||||
<string>en</string> |
||||
<key>CFBundleExecutable</key> |
||||
<string>Bolts</string> |
||||
<key>CFBundleIdentifier</key> |
||||
<string>com.bolts.boltsmac</string> |
||||
<key>CFBundleInfoDictionaryVersion</key> |
||||
<string>6.0</string> |
||||
<key>CFBundleName</key> |
||||
<string>Bolts</string> |
||||
<key>CFBundlePackageType</key> |
||||
<string>FMWK</string> |
||||
<key>CFBundleShortVersionString</key> |
||||
<string>1.5.0</string> |
||||
<key>CFBundleSignature</key> |
||||
<string>????</string> |
||||
<key>CFBundleSupportedPlatforms</key> |
||||
<array> |
||||
<string>MacOSX</string> |
||||
</array> |
||||
<key>CFBundleVersion</key> |
||||
<string>1.5.0</string> |
||||
<key>DTCompiler</key> |
||||
<string>com.apple.compilers.llvm.clang.1_0</string> |
||||
<key>DTPlatformBuild</key> |
||||
<string>7C68</string> |
||||
<key>DTPlatformVersion</key> |
||||
<string>GM</string> |
||||
<key>DTSDKBuild</key> |
||||
<string>15C43</string> |
||||
<key>DTSDKName</key> |
||||
<string>macosx10.11</string> |
||||
<key>DTXcode</key> |
||||
<string>0720</string> |
||||
<key>DTXcodeBuild</key> |
||||
<string>7C68</string> |
||||
</dict> |
||||
</plist> |
@ -0,0 +1 @@
|
||||
Versions/Current/Resources |
@ -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> |
||||
|
||||
///--------------------------------------
|
||||
/// @name 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; |
||||
|
||||
///--------------------------------------
|
||||
/// @name 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; |
||||
|
||||
///--------------------------------------
|
||||
/// @name 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; |
||||
|
||||
///--------------------------------------
|
||||
/// @name 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; |
||||
|
||||
///--------------------------------------
|
||||
/// @name 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 |
||||
|
||||
///--------------------------------------
|
||||
/// @name 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 PF_GENERIC(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 PF_GENERIC(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; |
||||
|
||||
///--------------------------------------
|
||||
/// @name 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 PF_GENERIC(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 PF_GENERIC(NSNumber *)*)trackEvent:(NSString *)name |
||||
dimensions:(nullable NSDictionary PF_GENERIC(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 PF_GENERIC(NSString *, NSString *)*)dimensions |
||||
block:(nullable PFBooleanResultBlock)block; |
||||
|
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
@ -0,0 +1,82 @@
|
||||
/**
|
||||
* 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 |
||||
|
||||
///--------------------------------------
|
||||
/// @name 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 PF_GENERIC(PFUser *)*)logInInBackground; |
||||
|
||||
/**
|
||||
Creates an anonymous user. |
||||
|
||||
@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; |
||||
|
||||
/*
|
||||
Creates an anonymous user. |
||||
|
||||
@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`. |
||||
*/ |
||||
+ (void)logInWithTarget:(nullable id)target selector:(nullable SEL)selector; |
||||
|
||||
///--------------------------------------
|
||||
/// @name 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,90 @@
|
||||
/**
|
||||
* 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 *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; |
||||
|
||||
/**
|
||||
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 PF_GENERIC(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; |
||||
|
||||
/*
|
||||
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. |
||||
*/ |
||||
+ (void)callFunctionInBackground:(NSString *)function |
||||
withParameters:(nullable NSDictionary *)parameters |
||||
target:(nullable id)target |
||||
selector:(nullable SEL)selector; |
||||
|
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
@ -0,0 +1,105 @@
|
||||
/**
|
||||
* 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 |
||||
|
||||
///--------------------------------------
|
||||
/// @name 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; |
||||
|
||||
///--------------------------------------
|
||||
/// @name 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; |
||||
|
||||
/**
|
||||
Gets the `PFConfig` *asynchronously* and sets it as a result of a task. |
||||
|
||||
@return The task, that encapsulates the work being done. |
||||
*/ |
||||
+ (BFTask PF_GENERIC(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; |
||||
|
||||
///--------------------------------------
|
||||
/// @name 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,557 @@
|
||||
/**
|
||||
* 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> |
||||
|
||||
@class PFObject; |
||||
@class PFUser; |
||||
|
||||
///--------------------------------------
|
||||
/// @name Version
|
||||
///--------------------------------------
|
||||
|
||||
#define PARSE_VERSION @"1.11.0" |
||||
|
||||
extern NSInteger const PARSE_API_VERSION; |
||||
|
||||
///--------------------------------------
|
||||
/// @name Platform
|
||||
///--------------------------------------
|
||||
|
||||
#define PARSE_IOS_ONLY (TARGET_OS_IPHONE) |
||||
#define PARSE_OSX_ONLY (TARGET_OS_MAC && !(TARGET_OS_IPHONE)) |
||||
|
||||
extern NSString *const __nonnull kPFDeviceType; |
||||
|
||||
///--------------------------------------
|
||||
/// @name Server
|
||||
///--------------------------------------
|
||||
|
||||
extern NSString *const __nonnull kPFParseServer; |
||||
|
||||
///--------------------------------------
|
||||
/// @name Cache Policies
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
`PFCachePolicy` specifies different caching policies that could be used with `PFQuery`. |
||||
|
||||
This lets you show data when the user's device is offline, |
||||
or when the app has just started and network requests have not yet had time to complete. |
||||
Parse takes care of automatically flushing the cache when it takes up too much space. |
||||
|
||||
@warning Cache policy could only be set when Local Datastore is not enabled. |
||||
|
||||
@see PFQuery |
||||
*/ |
||||
typedef NS_ENUM(uint8_t, PFCachePolicy) { |
||||
/**
|
||||
The query does not load from the cache or save results to the cache. |
||||
This is the default cache policy. |
||||
*/ |
||||
kPFCachePolicyIgnoreCache = 0, |
||||
/**
|
||||
The query only loads from the cache, ignoring the network. |
||||
If there are no cached results, this causes a `NSError` with `kPFErrorCacheMiss` code. |
||||
*/ |
||||
kPFCachePolicyCacheOnly, |
||||
/**
|
||||
The query does not load from the cache, but it will save results to the cache. |
||||
*/ |
||||
kPFCachePolicyNetworkOnly, |
||||
/**
|
||||
The query first tries to load from the cache, but if that fails, it loads results from the network. |
||||
If there are no cached results, this causes a `NSError` with `kPFErrorCacheMiss` code. |
||||
*/ |
||||
kPFCachePolicyCacheElseNetwork, |
||||
/**
|
||||
The query first tries to load from the network, but if that fails, it loads results from the cache. |
||||
If there are no cached results, this causes a `NSError` with `kPFErrorCacheMiss` code. |
||||
*/ |
||||
kPFCachePolicyNetworkElseCache, |
||||
/**
|
||||
The query first loads from the cache, then loads from the network. |
||||
The callback will be called twice - first with the cached results, then with the network results. |
||||
Since it returns two results at different times, this cache policy cannot be used with synchronous or task methods. |
||||
*/ |
||||
kPFCachePolicyCacheThenNetwork |
||||
}; |
||||
|
||||
///--------------------------------------
|
||||
/// @name Logging Levels
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
`PFLogLevel` enum specifies different levels of logging that could be used to limit or display more messages in logs. |
||||
|
||||
@see `Parse.+setLogLevel:` |
||||
@see `Parse.+logLevel` |
||||
*/ |
||||
typedef NS_ENUM(uint8_t, PFLogLevel) { |
||||
/**
|
||||
Log level that disables all logging. |
||||
*/ |
||||
PFLogLevelNone = 0, |
||||
/**
|
||||
Log level that if set is going to output error messages to the log. |
||||
*/ |
||||
PFLogLevelError = 1, |
||||
/**
|
||||
Log level that if set is going to output the following messages to log: |
||||
- Errors |
||||
- Warnings |
||||
*/ |
||||
PFLogLevelWarning = 2, |
||||
/**
|
||||
Log level that if set is going to output the following messages to log: |
||||
- Errors |
||||
- Warnings |
||||
- Informational messages |
||||
*/ |
||||
PFLogLevelInfo = 3, |
||||
/**
|
||||
Log level that if set is going to output the following messages to log: |
||||
- Errors |
||||
- Warnings |
||||
- Informational messages |
||||
- Debug messages |
||||
*/ |
||||
PFLogLevelDebug = 4 |
||||
}; |
||||
|
||||
///--------------------------------------
|
||||
/// @name Errors
|
||||
///--------------------------------------
|
||||
|
||||
extern NSString *const __nonnull PFParseErrorDomain; |
||||
|
||||
/**
|
||||
`PFErrorCode` enum contains all custom error codes that are used as `code` for `NSError` for callbacks on all classes. |
||||
|
||||
These codes are used when `domain` of `NSError` that you receive is set to `PFParseErrorDomain`. |
||||
*/ |
||||
typedef NS_ENUM(NSInteger, PFErrorCode) { |
||||
/**
|
||||
Internal server error. No information available. |
||||
*/ |
||||
kPFErrorInternalServer = 1, |
||||
/**
|
||||
The connection to the Parse servers failed. |
||||
*/ |
||||
kPFErrorConnectionFailed = 100, |
||||
/**
|
||||
Object doesn't exist, or has an incorrect password. |
||||
*/ |
||||
kPFErrorObjectNotFound = 101, |
||||
/**
|
||||
You tried to find values matching a datatype that doesn't |
||||
support exact database matching, like an array or a dictionary. |
||||
*/ |
||||
kPFErrorInvalidQuery = 102, |
||||
/**
|
||||
Missing or invalid classname. Classnames are case-sensitive. |
||||
They must start with a letter, and `a-zA-Z0-9_` are the only valid characters. |
||||
*/ |
||||
kPFErrorInvalidClassName = 103, |
||||
/**
|
||||
Missing object id. |
||||
*/ |
||||
kPFErrorMissingObjectId = 104, |
||||
/**
|
||||
Invalid key name. Keys are case-sensitive. |
||||
They must start with a letter, and `a-zA-Z0-9_` are the only valid characters. |
||||
*/ |
||||
kPFErrorInvalidKeyName = 105, |
||||
/**
|
||||
Malformed pointer. Pointers must be arrays of a classname and an object id. |
||||
*/ |
||||
kPFErrorInvalidPointer = 106, |
||||
/**
|
||||
Malformed json object. A json dictionary is expected. |
||||
*/ |
||||
kPFErrorInvalidJSON = 107, |
||||
/**
|
||||
Tried to access a feature only available internally. |
||||
*/ |
||||
kPFErrorCommandUnavailable = 108, |
||||
/**
|
||||
Field set to incorrect type. |
||||
*/ |
||||
kPFErrorIncorrectType = 111, |
||||
/**
|
||||
Invalid channel name. A channel name is either an empty string (the broadcast channel) |
||||
or contains only `a-zA-Z0-9_` characters and starts with a letter. |
||||
*/ |
||||
kPFErrorInvalidChannelName = 112, |
||||
/**
|
||||
Invalid device token. |
||||
*/ |
||||
kPFErrorInvalidDeviceToken = 114, |
||||
/**
|
||||
Push is misconfigured. See details to find out how. |
||||
*/ |
||||
kPFErrorPushMisconfigured = 115, |
||||
/**
|
||||
The object is too large. |
||||
*/ |
||||
kPFErrorObjectTooLarge = 116, |
||||
/**
|
||||
That operation isn't allowed for clients. |
||||
*/ |
||||
kPFErrorOperationForbidden = 119, |
||||
/**
|
||||
The results were not found in the cache. |
||||
*/ |
||||
kPFErrorCacheMiss = 120, |
||||
/**
|
||||
Keys in `NSDictionary` values may not include `$` or `.`. |
||||
*/ |
||||
kPFErrorInvalidNestedKey = 121, |
||||
/**
|
||||
Invalid file name. |
||||
A file name can contain only `a-zA-Z0-9_.` characters and should be between 1 and 36 characters. |
||||
*/ |
||||
kPFErrorInvalidFileName = 122, |
||||
/**
|
||||
Invalid ACL. An ACL with an invalid format was saved. This should not happen if you use `PFACL`. |
||||
*/ |
||||
kPFErrorInvalidACL = 123, |
||||
/**
|
||||
The request timed out on the server. Typically this indicates the request is too expensive. |
||||
*/ |
||||
kPFErrorTimeout = 124, |
||||
/**
|
||||
The email address was invalid. |
||||
*/ |
||||
kPFErrorInvalidEmailAddress = 125, |
||||
/**
|
||||
A unique field was given a value that is already taken. |
||||
*/ |
||||
kPFErrorDuplicateValue = 137, |
||||
/**
|
||||
Role's name is invalid. |
||||
*/ |
||||
kPFErrorInvalidRoleName = 139, |
||||
/**
|
||||
Exceeded an application quota. Upgrade to resolve. |
||||
*/ |
||||
kPFErrorExceededQuota = 140, |
||||
/**
|
||||
Cloud Code script had an error. |
||||
*/ |
||||
kPFScriptError = 141, |
||||
/**
|
||||
Cloud Code validation failed. |
||||
*/ |
||||
kPFValidationError = 142, |
||||
/**
|
||||
Product purchase receipt is missing. |
||||
*/ |
||||
kPFErrorReceiptMissing = 143, |
||||
/**
|
||||
Product purchase receipt is invalid. |
||||
*/ |
||||
kPFErrorInvalidPurchaseReceipt = 144, |
||||
/**
|
||||
Payment is disabled on this device. |
||||
*/ |
||||
kPFErrorPaymentDisabled = 145, |
||||
/**
|
||||
The product identifier is invalid. |
||||
*/ |
||||
kPFErrorInvalidProductIdentifier = 146, |
||||
/**
|
||||
The product is not found in the App Store. |
||||
*/ |
||||
kPFErrorProductNotFoundInAppStore = 147, |
||||
/**
|
||||
The Apple server response is not valid. |
||||
*/ |
||||
kPFErrorInvalidServerResponse = 148, |
||||
/**
|
||||
Product fails to download due to file system error. |
||||
*/ |
||||
kPFErrorProductDownloadFileSystemFailure = 149, |
||||
/**
|
||||
Fail to convert data to image. |
||||
*/ |
||||
kPFErrorInvalidImageData = 150, |
||||
/**
|
||||
Unsaved file. |
||||
*/ |
||||
kPFErrorUnsavedFile = 151, |
||||
/**
|
||||
Fail to delete file. |
||||
*/ |
||||
kPFErrorFileDeleteFailure = 153, |
||||
/**
|
||||
Application has exceeded its request limit. |
||||
*/ |
||||
kPFErrorRequestLimitExceeded = 155, |
||||
/**
|
||||
Invalid event name. |
||||
*/ |
||||
kPFErrorInvalidEventName = 160, |
||||
/**
|
||||
Username is missing or empty. |
||||
*/ |
||||
kPFErrorUsernameMissing = 200, |
||||
/**
|
||||
Password is missing or empty. |
||||
*/ |
||||
kPFErrorUserPasswordMissing = 201, |
||||
/**
|
||||
Username has already been taken. |
||||
*/ |
||||
kPFErrorUsernameTaken = 202, |
||||
/**
|
||||
Email has already been taken. |
||||
*/ |
||||
kPFErrorUserEmailTaken = 203, |
||||
/**
|
||||
The email is missing, and must be specified. |
||||
*/ |
||||
kPFErrorUserEmailMissing = 204, |
||||
/**
|
||||
A user with the specified email was not found. |
||||
*/ |
||||
kPFErrorUserWithEmailNotFound = 205, |
||||
/**
|
||||
The user cannot be altered by a client without the session. |
||||
*/ |
||||
kPFErrorUserCannotBeAlteredWithoutSession = 206, |
||||
/**
|
||||
Users can only be created through sign up. |
||||
*/ |
||||
kPFErrorUserCanOnlyBeCreatedThroughSignUp = 207, |
||||
/**
|
||||
An existing Facebook account already linked to another user. |
||||
*/ |
||||
kPFErrorFacebookAccountAlreadyLinked = 208, |
||||
/**
|
||||
An existing account already linked to another user. |
||||
*/ |
||||
kPFErrorAccountAlreadyLinked = 208, |
||||
/**
|
||||
Error code indicating that the current session token is invalid. |
||||
*/ |
||||
kPFErrorInvalidSessionToken = 209, |
||||
kPFErrorUserIdMismatch = 209, |
||||
/**
|
||||
Facebook id missing from request. |
||||
*/ |
||||
kPFErrorFacebookIdMissing = 250, |
||||
/**
|
||||
Linked id missing from request. |
||||
*/ |
||||
kPFErrorLinkedIdMissing = 250, |
||||
/**
|
||||
Invalid Facebook session. |
||||
*/ |
||||
kPFErrorFacebookInvalidSession = 251, |
||||
/**
|
||||
Invalid linked session. |
||||
*/ |
||||
kPFErrorInvalidLinkedSession = 251, |
||||
}; |
||||
|
||||
///--------------------------------------
|
||||
/// @name Blocks
|
||||
///--------------------------------------
|
||||
|
||||
typedef void (^PFBooleanResultBlock)(BOOL succeeded, NSError *__nullable error); |
||||
typedef void (^PFIntegerResultBlock)(int number, NSError *__nullable error); |
||||
typedef void (^PFArrayResultBlock)(NSArray *__nullable objects, NSError *__nullable error); |
||||
typedef void (^PFObjectResultBlock)(PFObject *__nullable object, NSError *__nullable error); |
||||
typedef void (^PFSetResultBlock)(NSSet *__nullable channels, NSError *__nullable error); |
||||
typedef void (^PFUserResultBlock)(PFUser *__nullable user, NSError *__nullable error); |
||||
typedef void (^PFDataResultBlock)(NSData *__nullable data, NSError *__nullable error); |
||||
typedef void (^PFDataStreamResultBlock)(NSInputStream *__nullable stream, NSError *__nullable error); |
||||
typedef void (^PFFilePathResultBlock)(NSString *__nullable filePath, NSError *__nullable error); |
||||
typedef void (^PFStringResultBlock)(NSString *__nullable string, NSError *__nullable error); |
||||
typedef void (^PFIdResultBlock)(__nullable id object, NSError *__nullable error); |
||||
typedef void (^PFProgressBlock)(int percentDone); |
||||
|
||||
///--------------------------------------
|
||||
/// @name Network Notifications
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
The name of the notification that is going to be sent before any URL request is sent. |
||||
*/ |
||||
extern NSString *const __nonnull PFNetworkWillSendURLRequestNotification; |
||||
|
||||
/**
|
||||
The name of the notification that is going to be sent after any URL response is received. |
||||
*/ |
||||
extern NSString *const __nonnull PFNetworkDidReceiveURLResponseNotification; |
||||
|
||||
/**
|
||||
The key of request(NSURLRequest) in the userInfo dictionary of a notification. |
||||
@note This key is populated in userInfo, only if `PFLogLevel` on `Parse` is set to `PFLogLevelDebug`. |
||||
*/ |
||||
extern NSString *const __nonnull PFNetworkNotificationURLRequestUserInfoKey; |
||||
|
||||
/**
|
||||
The key of response(NSHTTPURLResponse) in the userInfo dictionary of a notification. |
||||
@note This key is populated in userInfo, only if `PFLogLevel` on `Parse` is set to `PFLogLevelDebug`. |
||||
*/ |
||||
extern NSString *const __nonnull PFNetworkNotificationURLResponseUserInfoKey; |
||||
|
||||
/**
|
||||
The key of repsonse body (usually `NSString` with JSON) in the userInfo dictionary of a notification. |
||||
@note This key is populated in userInfo, only if `PFLogLevel` on `Parse` is set to `PFLogLevelDebug`. |
||||
*/ |
||||
extern NSString *const __nonnull PFNetworkNotificationURLResponseBodyUserInfoKey; |
||||
|
||||
|
||||
///--------------------------------------
|
||||
/// @name Deprecated Macros
|
||||
///--------------------------------------
|
||||
|
||||
#ifndef PARSE_DEPRECATED |
||||
# ifdef __deprecated_msg |
||||
# define PARSE_DEPRECATED(_MSG) __deprecated_msg(_MSG) |
||||
# else |
||||
# ifdef __deprecated |
||||
# define PARSE_DEPRECATED(_MSG) __attribute__((deprecated)) |
||||
# else |
||||
# define PARSE_DEPRECATED(_MSG) |
||||
# endif |
||||
# endif |
||||
#endif |
||||
|
||||
///--------------------------------------
|
||||
/// @name Extensions Macros
|
||||
///--------------------------------------
|
||||
|
||||
#ifndef PF_EXTENSION_UNAVAILABLE |
||||
# if PARSE_IOS_ONLY |
||||
# ifdef NS_EXTENSION_UNAVAILABLE_IOS |
||||
# define PF_EXTENSION_UNAVAILABLE(_msg) NS_EXTENSION_UNAVAILABLE_IOS(_msg) |
||||
# else |
||||
# define PF_EXTENSION_UNAVAILABLE(_msg) |
||||
# endif |
||||
# else |
||||
# ifdef NS_EXTENSION_UNAVAILABLE_MAC |
||||
# define PF_EXTENSION_UNAVAILABLE(_msg) NS_EXTENSION_UNAVAILABLE_MAC(_msg) |
||||
# else |
||||
# define PF_EXTENSION_UNAVAILABLE(_msg) |
||||
# endif |
||||
# endif |
||||
#endif |
||||
|
||||
///--------------------------------------
|
||||
/// @name Swift Macros
|
||||
///--------------------------------------
|
||||
|
||||
#ifndef PF_SWIFT_UNAVAILABLE |
||||
# ifdef NS_SWIFT_UNAVAILABLE |
||||
# define PF_SWIFT_UNAVAILABLE NS_SWIFT_UNAVAILABLE("") |
||||
# else |
||||
# define PF_SWIFT_UNAVAILABLE |
||||
# endif |
||||
#endif |
||||
|
||||
///--------------------------------------
|
||||
/// @name Obj-C Generics Macros
|
||||
///--------------------------------------
|
||||
|
||||
#if __has_feature(objc_generics) || __has_extension(objc_generics) |
||||
# define PF_GENERIC(...) <__VA_ARGS__> |
||||
#else |
||||
# define PF_GENERIC(...) |
||||
# define PFGenericObject PFObject * |
||||
#endif |
||||
|
||||
///--------------------------------------
|
||||
/// @name Platform Availability Defines
|
||||
///--------------------------------------
|
||||
|
||||
#ifndef TARGET_OS_IOS |
||||
# define TARGET_OS_IOS TARGET_OS_IPHONE |
||||
#endif |
||||
#ifndef TARGET_OS_WATCH |
||||
# define TARGET_OS_WATCH 0 |
||||
#endif |
||||
#ifndef TARGET_OS_TV |
||||
# define TARGET_OS_TV 0 |
||||
#endif |
||||
|
||||
#ifndef PF_TARGET_OS_OSX |
||||
# define PF_TARGET_OS_OSX TARGET_OS_MAC && !TARGET_OS_IOS && !TARGET_OS_WATCH && !TARGET_OS_TV |
||||
#endif |
||||
|
||||
///--------------------------------------
|
||||
/// @name Avaiability Macros
|
||||
///--------------------------------------
|
||||
|
||||
#ifndef PF_IOS_UNAVAILABLE |
||||
# ifdef __IOS_UNAVILABLE |
||||
# define PF_IOS_UNAVAILABLE __IOS_UNAVAILABLE |
||||
# else |
||||
# define PF_IOS_UNAVAILABLE |
||||
# endif |
||||
#endif |
||||
|
||||
#ifndef PF_IOS_UNAVAILABLE_WARNING |
||||
# if TARGET_OS_IOS |
||||
# define PF_IOS_UNAVAILABLE_WARNING _Pragma("GCC warning \"This file is unavailable on iOS.\"") |
||||
# else |
||||
# define PF_IOS_UNAVAILABLE_WARNING |
||||
# endif |
||||
#endif |
||||
|
||||
#ifndef PF_OSX_UNAVAILABLE |
||||
# if PF_TARGET_OS_OSX |
||||
# define PF_OSX_UNAVAILABLE __OSX_UNAVAILABLE |
||||
# else |
||||
# define PF_OSX_UNAVAILABLE |
||||
# endif |
||||
#endif |
||||
|
||||
#ifndef PF_OSX_UNAVAILABLE_WARNING |
||||
# if PF_TARGET_OS_OSX |
||||
# define PF_OSX_UNAVAILABLE_WARNING _Pragma("GCC warning \"This file is unavailable on OS X.\"") |
||||
# else |
||||
# define PF_OSX_UNAVAILABLE_WARNING |
||||
# endif |
||||
#endif |
||||
|
||||
#ifndef PF_WATCH_UNAVAILABLE |
||||
# ifdef __WATCHOS_UNAVAILABLE |
||||
# define PF_WATCH_UNAVAILABLE __WATCHOS_UNAVAILABLE |
||||
# else |
||||
# define PF_WATCH_UNAVAILABLE |
||||
# endif |
||||
#endif |
||||
|
||||
#ifndef PF_WATCH_UNAVAILABLE_WARNING |
||||
# if TARGET_OS_WATCH |
||||
# define PF_WATCH_UNAVAILABLE_WARNING _Pragma("GCC warning \"This file is unavailable on watchOS.\"") |
||||
# else |
||||
# define PF_WATCH_UNAVAILABLE_WARNING |
||||
# endif |
||||
#endif |
||||
|
||||
#ifndef PF_TV_UNAVAILABLE |
||||
# ifdef __TVOS_PROHIBITED |
||||
# define PF_TV_UNAVAILABLE __TVOS_PROHIBITED |
||||
# else |
||||
# define PF_TV_UNAVAILABLE |
||||
# endif |
||||
#endif |
||||
|
||||
#ifndef PF_TV_UNAVAILABLE_WARNING |
||||
# if TARGET_OS_TV |
||||
# define PF_TV_UNAVAILABLE_WARNING _Pragma("GCC warning \"This file is unavailable on tvOS.\"") |
||||
# else |
||||
# define PF_TV_UNAVAILABLE_WARNING |
||||
# endif |
||||
#endif |
@ -0,0 +1,444 @@
|
||||
/**
|
||||
* 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 |
||||
|
||||
///--------------------------------------
|
||||
/// @name 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; |
||||
|
||||
///--------------------------------------
|
||||
/// @name 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; |
||||
|
||||
///--------------------------------------
|
||||
/// @name 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; |
||||
|
||||
/**
|
||||
Saves the file *asynchronously*. |
||||
|
||||
@return The task, that encapsulates the work being done. |
||||
*/ |
||||
- (BFTask PF_GENERIC(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 PF_GENERIC(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; |
||||
|
||||
/*
|
||||
Saves the file *asynchronously* and calls the given callback. |
||||
|
||||
@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. |
||||
*/ |
||||
- (void)saveInBackgroundWithTarget:(nullable id)target selector:(nullable SEL)selector; |
||||
|
||||
///--------------------------------------
|
||||
/// @name 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; |
||||
|
||||
/**
|
||||
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; |
||||
|
||||
/**
|
||||
*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. |
||||
|
||||
@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; |
||||
|
||||
/**
|
||||
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 PF_GENERIC(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 PF_GENERIC(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 PF_GENERIC(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 PF_GENERIC(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 PF_GENERIC(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 PF_GENERIC(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 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. |
||||
*/ |
||||
- (void)getDataInBackgroundWithTarget:(nullable id)target selector:(nullable SEL)selector; |
||||
|
||||
/**
|
||||
*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 PF_GENERIC(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 PF_GENERIC(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; |
||||
|
||||
///--------------------------------------
|
||||
/// @name 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> |
||||
|
||||
///--------------------------------------
|
||||
/// @name 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; |
||||
|
||||
///--------------------------------------
|
||||
/// @name 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; |
||||
|
||||
///--------------------------------------
|
||||
/// @name 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> |
||||
|
||||
///--------------------------------------
|
||||
/// @name 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; |
||||
|
||||
///--------------------------------------
|
||||
/// @name 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 PF_GENERIC(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; |
||||
|
||||
///--------------------------------------
|
||||
/// @name 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 |
@ -0,0 +1,126 @@
|
||||
/**
|
||||
* 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> |
||||
|
||||
@class PFQuery PF_GENERIC(PFGenericObject : PFObject *); |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
/**
|
||||
### Subclassing Notes |
||||
|
||||
Developers can subclass `PFObject` for a more native object-oriented class structure. |
||||
Strongly-typed subclasses of `PFObject` must conform to the `PFSubclassing` protocol |
||||
and must call `PFSubclassing.+registerSubclass` before `Parse.+setApplicationId:clientKey:` is called. |
||||
After this it will be returned by `PFQuery` and other `PFObject` factories. |
||||
|
||||
All methods in `PFSubclassing` except for `PFSubclassing.+parseClassName` |
||||
are already implemented in the `PFObject(Subclass)` category. |
||||
|
||||
Including `PFObject+Subclass.h` in your implementation file provides these implementations automatically. |
||||
|
||||
Subclasses support simpler initializers, query syntax, and dynamic synthesizers. |
||||
The following shows an example subclass: |
||||
|
||||
\@interface MYGame : PFObject <PFSubclassing> |
||||
|
||||
// Accessing this property is the same as objectForKey:@"title"
|
||||
@property (nonatomic, copy) NSString *title; |
||||
|
||||
+ (NSString *)parseClassName; |
||||
|
||||
@end |
||||
|
||||
|
||||
@implementation MYGame |
||||
|
||||
@dynamic title; |
||||
|
||||
+ (NSString *)parseClassName { |
||||
return @"Game"; |
||||
} |
||||
|
||||
@end |
||||
|
||||
|
||||
MYGame *game = [[MYGame alloc] init]; |
||||
game.title = @"Bughouse"; |
||||
[game saveInBackground]; |
||||
*/ |
||||
@interface PFObject (Subclass) |
||||
|
||||
///--------------------------------------
|
||||
/// @name Methods for Subclasses
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
Creates an instance of the registered subclass with this class's `PFSubclassing.+parseClassName`. |
||||
|
||||
This helps a subclass ensure that it can be subclassed itself. |
||||
For example, `[PFUser object]` will return a `MyUser` object if `MyUser` is a registered subclass of `PFUser`. |
||||
For this reason, `[MyClass object]` is preferred to `[[MyClass alloc] init]`. |
||||
This method can only be called on subclasses which conform to `PFSubclassing`. |
||||
A default implementation is provided by `PFObject` which should always be sufficient. |
||||
*/ |
||||
+ (instancetype)object; |
||||
|
||||
/**
|
||||
Creates a reference to an existing `PFObject` for use in creating associations between `PFObjects`. |
||||
|
||||
Calling `dataAvailable` on this object will return `NO` until `-fetchIfNeeded` or `-fetch` has been called. |
||||
This method can only be called on subclasses which conform to `PFSubclassing`. |
||||
A default implementation is provided by `PFObject` which should always be sufficient. |
||||
No network request will be made. |
||||
|
||||
@param objectId The object id for the referenced object. |
||||
|
||||
@return An instance of `PFObject` without data. |
||||
*/ |
||||
+ (instancetype)objectWithoutDataWithObjectId:(nullable NSString *)objectId; |
||||
|
||||
/**
|
||||
Registers an Objective-C class for Parse to use for representing a given Parse class. |
||||
|
||||
Once this is called on a `PFObject` subclass, any `PFObject` Parse creates with a class name |
||||
that matches `[self parseClassName]` will be an instance of subclass. |
||||
This method can only be called on subclasses which conform to `PFSubclassing`. |
||||
A default implementation is provided by `PFObject` which should always be sufficient. |
||||
*/ |
||||
+ (void)registerSubclass; |
||||
|
||||
/**
|
||||
Returns a query for objects of type `PFSubclassing.+parseClassName`. |
||||
|
||||
This method can only be called on subclasses which conform to `PFSubclassing`. |
||||
A default implementation is provided by `PFObject` which should always be sufficient. |
||||
|
||||
@see `PFQuery` |
||||
*/ |
||||
+ (nullable PFQuery *)query; |
||||
|
||||
/**
|
||||
Returns a query for objects of type `PFSubclassing.+parseClassName` with a given predicate. |
||||
|
||||
A default implementation is provided by `PFObject` which should always be sufficient. |
||||
@warning This method can only be called on subclasses which conform to `PFSubclassing`. |
||||
|
||||
@param predicate The predicate to create conditions from. |
||||
|
||||
@return An instance of `PFQuery`. |
||||
|
||||
@see `PFQuery.+queryWithClassName:predicate:` |
||||
*/ |
||||
+ (nullable PFQuery *)queryWithPredicate:(nullable NSPredicate *)predicate; |
||||
|
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,543 @@
|
||||
/**
|
||||
* 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/PFInstallation.h> |
||||
|
||||
PF_TV_UNAVAILABLE_WARNING |
||||
PF_WATCH_UNAVAILABLE_WARNING |
||||
|
||||
@class PFQuery PF_GENERIC(PFGenericObject : PFObject *); |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
/**
|
||||
The `PFPush` class defines a push notification that can be sent from a client device. |
||||
|
||||
The preferred way of modifying or retrieving channel subscriptions is to use |
||||
the `PFInstallation` class, instead of the class methods in `PFPush`. |
||||
*/ |
||||
PF_TV_UNAVAILABLE PF_WATCH_UNAVAILABLE @interface PFPush : NSObject <NSCopying> |
||||
|
||||
///--------------------------------------
|
||||
/// @name Creating a Push Notification
|
||||
///--------------------------------------
|
||||
|
||||
+ (instancetype)push; |
||||
|
||||
///--------------------------------------
|
||||
/// @name Configuring a Push Notification
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
Sets the channel on which this push notification will be sent. |
||||
|
||||
@param channel The channel to set for this push. |
||||
The channel name must start with a letter and contain only letters, numbers, dashes, and underscores. |
||||
*/ |
||||
- (void)setChannel:(nullable NSString *)channel; |
||||
|
||||
/**
|
||||
Sets the array of channels on which this push notification will be sent. |
||||
|
||||
@param channels The array of channels to set for this push. |
||||
Each channel name must start with a letter and contain only letters, numbers, dashes, and underscores. |
||||
*/ |
||||
- (void)setChannels:(nullable NSArray PF_GENERIC(NSString *)*)channels; |
||||
|
||||
/**
|
||||
Sets an installation query to which this push notification will be sent. |
||||
|
||||
The query should be created via `PFInstallation.+query` and should not specify a skip, limit, or order. |
||||
|
||||
@param query The installation query to set for this push. |
||||
*/ |
||||
- (void)setQuery:(nullable PFQuery PF_GENERIC(PFInstallation *)*)query; |
||||
|
||||
/**
|
||||
Sets an alert message for this push notification. |
||||
|
||||
@warning This will overwrite any data specified in setData. |
||||
|
||||
@param message The message to send in this push. |
||||
*/ |
||||
- (void)setMessage:(nullable NSString *)message; |
||||
|
||||
/**
|
||||
Sets an arbitrary data payload for this push notification. |
||||
|
||||
See the guide for information about the dictionary structure. |
||||
|
||||
@warning This will overwrite any data specified in setMessage. |
||||
|
||||
@param data The data to send in this push. |
||||
*/ |
||||
- (void)setData:(nullable NSDictionary *)data; |
||||
|
||||
/**
|
||||
Sets whether this push will go to Android devices. |
||||
|
||||
@param pushToAndroid Whether this push will go to Android devices. |
||||
|
||||
@deprecated Please use a `PFInstallation.+query` with a constraint on deviceType instead. |
||||
*/ |
||||
- (void)setPushToAndroid:(BOOL)pushToAndroid PARSE_DEPRECATED("Please use a [PFInstallation query] with a constraint on deviceType. This method is deprecated and won't do anything."); |
||||
|
||||
/**
|
||||
Sets whether this push will go to iOS devices. |
||||
|
||||
@param pushToIOS Whether this push will go to iOS devices. |
||||
|
||||
@deprecated Please use a `PFInstallation.+query` with a constraint on deviceType instead. |
||||
*/ |
||||
- (void)setPushToIOS:(BOOL)pushToIOS PARSE_DEPRECATED("Please use a [PFInstallation query] with a constraint on deviceType. This method is deprecated and won't do anything."); |
||||
|
||||
/**
|
||||
Sets the expiration time for this notification. |
||||
|
||||
The notification will be sent to devices which are either online |
||||
at the time the notification is sent, or which come online before the expiration time is reached. |
||||
Because device clocks are not guaranteed to be accurate, |
||||
most applications should instead use `-expireAfterTimeInterval:`. |
||||
|
||||
@see expireAfterTimeInterval: |
||||
|
||||
@param date The time at which the notification should expire. |
||||
*/ |
||||
- (void)expireAtDate:(nullable NSDate *)date; |
||||
|
||||
/**
|
||||
Sets the time interval after which this notification should expire. |
||||
|
||||
This notification will be sent to devices which are either online at |
||||
the time the notification is sent, or which come online within the given |
||||
time interval of the notification being received by Parse's server. |
||||
An interval which is less than or equal to zero indicates that the |
||||
message should only be sent to devices which are currently online. |
||||
|
||||
@param timeInterval The interval after which the notification should expire. |
||||
*/ |
||||
- (void)expireAfterTimeInterval:(NSTimeInterval)timeInterval; |
||||
|
||||
/**
|
||||
Clears both expiration values, indicating that the notification should never expire. |
||||
*/ |
||||
- (void)clearExpiration; |
||||
|
||||
/**
|
||||
Date at which to send this push notification. |
||||
|
||||
Push notificaitons with this date will be delivered at the local time matching the `PFInstallation.timeZone`. |
||||
|
||||
@warning The date cannot be in the past, and can be up to two weeks in the future. |
||||
*/ |
||||
@property (nullable, nonatomic, strong) NSDate *pushDate; |
||||
|
||||
///--------------------------------------
|
||||
/// @name Sending Push Notifications
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
*Synchronously* send a push message to a channel. |
||||
|
||||
@param channel The channel to send to. The channel name must start with |
||||
a letter and contain only letters, numbers, dashes, and underscores. |
||||
@param message The message to send. |
||||
@param error Pointer to an `NSError` that will be set if necessary. |
||||
|
||||
@return Returns whether the send succeeded. |
||||
*/ |
||||
+ (BOOL)sendPushMessageToChannel:(NSString *)channel |
||||
withMessage:(NSString *)message |
||||
error:(NSError **)error; |
||||
|
||||
/**
|
||||
*Asynchronously* send a push message to a channel. |
||||
|
||||
@param channel The channel to send to. The channel name must start with |
||||
a letter and contain only letters, numbers, dashes, and underscores. |
||||
@param message The message to send. |
||||
|
||||
@return The task, that encapsulates the work being done. |
||||
*/ |
||||
+ (BFTask PF_GENERIC(NSNumber *)*)sendPushMessageToChannelInBackground:(NSString *)channel |
||||
withMessage:(NSString *)message; |
||||
|
||||
/**
|
||||
*Asynchronously* sends a push message to a channel and calls the given block. |
||||
|
||||
@param channel The channel to send to. The channel name must start with |
||||
a letter and contain only letters, numbers, dashes, and underscores. |
||||
@param message The message to send. |
||||
@param block The block to execute. |
||||
It should have the following argument signature: `^(BOOL succeeded, NSError *error)` |
||||
*/ |
||||
+ (void)sendPushMessageToChannelInBackground:(NSString *)channel |
||||
withMessage:(NSString *)message |
||||
block:(nullable PFBooleanResultBlock)block; |
||||
|
||||
/*
|
||||
*Asynchronously* send a push message to a channel. |
||||
|
||||
@param channel The channel to send to. The channel name must start with |
||||
a letter and contain only letters, numbers, dashes, and underscores. |
||||
@param message The message to send. |
||||
@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. |
||||
*/ |
||||
+ (void)sendPushMessageToChannelInBackground:(NSString *)channel |
||||
withMessage:(NSString *)message |
||||
target:(__nullable id)target |
||||
selector:(__nullable SEL)selector; |
||||
|
||||
/**
|
||||
Send a push message to a query. |
||||
|
||||
@param query The query to send to. The query must be a `PFInstallation` query created with `PFInstallation.+query`. |
||||
@param message The message to send. |
||||
@param error Pointer to an NSError that will be set if necessary. |
||||
|
||||
@return Returns whether the send succeeded. |
||||
*/ |
||||
+ (BOOL)sendPushMessageToQuery:(PFQuery PF_GENERIC(PFInstallation *)*)query |
||||
withMessage:(NSString *)message |
||||
error:(NSError **)error; |
||||
|
||||
/**
|
||||
*Asynchronously* send a push message to a query. |
||||
|
||||
@param query The query to send to. The query must be a `PFInstallation` query created with `PFInstallation.+query`. |
||||
@param message The message to send. |
||||
|
||||
@return The task, that encapsulates the work being done. |
||||
*/ |
||||
+ (BFTask PF_GENERIC(NSNumber *)*)sendPushMessageToQueryInBackground:(PFQuery PF_GENERIC(PFInstallation *)*)query |
||||
withMessage:(NSString *)message; |
||||
|
||||
/**
|
||||
*Asynchronously* sends a push message to a query and calls the given block. |
||||
|
||||
@param query The query to send to. The query must be a PFInstallation query |
||||
created with [PFInstallation query]. |
||||
@param message The message to send. |
||||
@param block The block to execute. |
||||
It should have the following argument signature: `^(BOOL succeeded, NSError *error)` |
||||
*/ |
||||
+ (void)sendPushMessageToQueryInBackground:(PFQuery PF_GENERIC(PFInstallation *)*)query |
||||
withMessage:(NSString *)message |
||||
block:(nullable PFBooleanResultBlock)block; |
||||
|
||||
/**
|
||||
*Synchronously* send this push message. |
||||
|
||||
@param error Pointer to an `NSError` that will be set if necessary. |
||||
|
||||
@return Returns whether the send succeeded. |
||||
*/ |
||||
- (BOOL)sendPush:(NSError **)error; |
||||
|
||||
/**
|
||||
*Asynchronously* send this push message. |
||||
@return The task, that encapsulates the work being done. |
||||
*/ |
||||
- (BFTask PF_GENERIC(NSNumber *)*)sendPushInBackground; |
||||
|
||||
/**
|
||||
*Asynchronously* send this push message and executes the given callback block. |
||||
|
||||
@param block The block to execute. |
||||
It should have the following argument signature: `^(BOOL succeeded, NSError *error)`. |
||||
*/ |
||||
- (void)sendPushInBackgroundWithBlock:(nullable PFBooleanResultBlock)block; |
||||
|
||||
/*
|
||||
*Asynchronously* send this push message and calls the given callback. |
||||
|
||||
@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. |
||||
*/ |
||||
- (void)sendPushInBackgroundWithTarget:(__nullable id)target selector:(__nullable SEL)selector; |
||||
|
||||
/**
|
||||
*Synchronously* send a push message with arbitrary data to a channel. |
||||
|
||||
See the guide for information about the dictionary structure. |
||||
|
||||
@param channel The channel to send to. The channel name must start with |
||||
a letter and contain only letters, numbers, dashes, and underscores. |
||||
@param data The data to send. |
||||
@param error Pointer to an NSError that will be set if necessary. |
||||
|
||||
@return Returns whether the send succeeded. |
||||
*/ |
||||
+ (BOOL)sendPushDataToChannel:(NSString *)channel |
||||
withData:(NSDictionary *)data |
||||
error:(NSError **)error; |
||||
|
||||
/**
|
||||
*Asynchronously* send a push message with arbitrary data to a channel. |
||||
|
||||
See the guide for information about the dictionary structure. |
||||
|
||||
@param channel The channel to send to. The channel name must start with |
||||
a letter and contain only letters, numbers, dashes, and underscores. |
||||
@param data The data to send. |
||||
|
||||
@return The task, that encapsulates the work being done. |
||||
*/ |
||||
+ (BFTask PF_GENERIC(NSNumber *)*)sendPushDataToChannelInBackground:(NSString *)channel |
||||
withData:(NSDictionary *)data; |
||||
|
||||
/**
|
||||
Asynchronously sends a push message with arbitrary data to a channel and calls the given block. |
||||
|
||||
See the guide for information about the dictionary structure. |
||||
|
||||
@param channel The channel to send to. The channel name must start with |
||||
a letter and contain only letters, numbers, dashes, and underscores. |
||||
@param data The data to send. |
||||
@param block The block to execute. |
||||
It should have the following argument signature: `^(BOOL succeeded, NSError *error)`. |
||||
*/ |
||||
+ (void)sendPushDataToChannelInBackground:(NSString *)channel |
||||
withData:(NSDictionary *)data |
||||
block:(nullable PFBooleanResultBlock)block; |
||||
|
||||
/*
|
||||
*Asynchronously* send a push message with arbitrary data to a channel. |
||||
|
||||
See the guide for information about the dictionary structure. |
||||
|
||||
@param channel The channel to send to. The channel name must start with |
||||
a letter and contain only letters, numbers, dashes, and underscores. |
||||
@param data The data to send. |
||||
@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. |
||||
*/ |
||||
+ (void)sendPushDataToChannelInBackground:(NSString *)channel |
||||
withData:(NSDictionary *)data |
||||
target:(__nullable id)target |
||||
selector:(__nullable SEL)selector; |
||||
|
||||
/**
|
||||
*Synchronously* send a push message with arbitrary data to a query. |
||||
|
||||
See the guide for information about the dictionary structure. |
||||
|
||||
@param query The query to send to. The query must be a `PFInstallation` query |
||||
created with `PFInstallation.+query`. |
||||
@param data The data to send. |
||||
@param error Pointer to an NSError that will be set if necessary. |
||||
|
||||
@return Returns whether the send succeeded. |
||||
*/ |
||||
+ (BOOL)sendPushDataToQuery:(PFQuery PF_GENERIC(PFInstallation *)*)query |
||||
withData:(NSDictionary *)data |
||||
error:(NSError **)error; |
||||
|
||||
/**
|
||||
Asynchronously send a push message with arbitrary data to a query. |
||||
|
||||
See the guide for information about the dictionary structure. |
||||
|
||||
@param query The query to send to. The query must be a `PFInstallation` query |
||||
created with `PFInstallation.+query`. |
||||
@param data The data to send. |
||||
|
||||
@return The task, that encapsulates the work being done. |
||||
*/ |
||||
+ (BFTask PF_GENERIC(NSNumber *)*)sendPushDataToQueryInBackground:(PFQuery PF_GENERIC(PFInstallation *)*)query |
||||
withData:(NSDictionary *)data; |
||||
|
||||
/**
|
||||
*Asynchronously* sends a push message with arbitrary data to a query and calls the given block. |
||||
|
||||
See the guide for information about the dictionary structure. |
||||
|
||||
@param query The query to send to. The query must be a `PFInstallation` query |
||||
created with `PFInstallation.+query`. |
||||
@param data The data to send. |
||||
@param block The block to execute. |
||||
It should have the following argument signature: `^(BOOL succeeded, NSError *error)`. |
||||
*/ |
||||
+ (void)sendPushDataToQueryInBackground:(PFQuery PF_GENERIC(PFInstallation *)*)query |
||||
withData:(NSDictionary *)data |
||||
block:(nullable PFBooleanResultBlock)block; |
||||
|
||||
///--------------------------------------
|
||||
/// @name Handling Notifications
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
A default handler for push notifications while the app is active that |
||||
could be used to mimic the behavior of iOS push notifications while the app is backgrounded or not running. |
||||
|
||||
Call this from `application:didReceiveRemoteNotification:`. |
||||
If push has a dictionary containing loc-key and loc-args in the alert, |
||||
we support up to 10 items in loc-args (`NSRangeException` if limit exceeded). |
||||
|
||||
@warning This method is available only on iOS. |
||||
|
||||
@param userInfo The userInfo dictionary you get in `appplication:didReceiveRemoteNotification:`. |
||||
*/ |
||||
+ (void)handlePush:(nullable NSDictionary *)userInfo NS_AVAILABLE_IOS(3_0) PF_EXTENSION_UNAVAILABLE(""); |
||||
|
||||
///--------------------------------------
|
||||
/// @name Managing Channel Subscriptions
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
Store the device token locally for push notifications. |
||||
|
||||
Usually called from you main app delegate's `didRegisterForRemoteNotificationsWithDeviceToken:`. |
||||
|
||||
@param deviceToken Either as an `NSData` straight from `application:didRegisterForRemoteNotificationsWithDeviceToken:` |
||||
or as an `NSString` if you converted it yourself. |
||||
*/ |
||||
+ (void)storeDeviceToken:(id)deviceToken; |
||||
|
||||
/**
|
||||
*Synchronously* get all the channels that this device is subscribed to. |
||||
|
||||
@param error Pointer to an `NSError` that will be set if necessary. |
||||
|
||||
@return Returns an `NSSet` containing all the channel names this device is subscribed to. |
||||
*/ |
||||
+ (nullable NSSet PF_GENERIC(NSString *)*)getSubscribedChannels:(NSError **)error; |
||||
|
||||
/**
|
||||
*Asynchronously* get all the channels that this device is subscribed to. |
||||
|
||||
@return The task, that encapsulates the work being done. |
||||
*/ |
||||
+ (BFTask PF_GENERIC(NSSet<NSString *> *)*)getSubscribedChannelsInBackground; |
||||
|
||||
/**
|
||||
*Asynchronously* get all the channels that this device is subscribed to. |
||||
@param block The block to execute. |
||||
It should have the following argument signature: `^(NSSet *channels, NSError *error)`. |
||||
*/ |
||||
+ (void)getSubscribedChannelsInBackgroundWithBlock:(PFSetResultBlock)block; |
||||
|
||||
/*
|
||||
*Asynchronously* get all the channels that this device is subscribed to. |
||||
|
||||
@param target The object to call selector on. |
||||
@param selector The selector to call. |
||||
It should have the following signature: `(void)callbackWithResult:(NSSet *)result error:(NSError *)error`. |
||||
`error` will be `nil` on success and set if there was an error. |
||||
*/ |
||||
+ (void)getSubscribedChannelsInBackgroundWithTarget:(id)target selector:(SEL)selector; |
||||
|
||||
/**
|
||||
*Synchrnously* subscribes the device to a channel of push notifications. |
||||
|
||||
@param channel The channel to subscribe to. The channel name must start with |
||||
a letter and contain only letters, numbers, dashes, and underscores. |
||||
@param error Pointer to an `NSError` that will be set if necessary. |
||||
|
||||
@return Returns whether the subscribe succeeded. |
||||
*/ |
||||
+ (BOOL)subscribeToChannel:(NSString *)channel error:(NSError **)error; |
||||
|
||||
/**
|
||||
*Asynchronously* subscribes the device to a channel of push notifications. |
||||
|
||||
@param channel The channel to subscribe to. The channel name must start with |
||||
a letter and contain only letters, numbers, dashes, and underscores. |
||||
|
||||
@return The task, that encapsulates the work being done. |
||||
*/ |
||||
+ (BFTask PF_GENERIC(NSNumber *)*)subscribeToChannelInBackground:(NSString *)channel; |
||||
|
||||
/**
|
||||
*Asynchronously* subscribes the device to a channel of push notifications and calls the given block. |
||||
|
||||
@param channel The channel to subscribe to. The channel name must start with |
||||
a letter and contain only letters, numbers, dashes, and underscores. |
||||
@param block The block to execute. |
||||
It should have the following argument signature: `^(BOOL succeeded, NSError *error)` |
||||
*/ |
||||
+ (void)subscribeToChannelInBackground:(NSString *)channel |
||||
block:(nullable PFBooleanResultBlock)block; |
||||
|
||||
/*
|
||||
*Asynchronously* subscribes the device to a channel of push notifications and calls the given callback. |
||||
|
||||
@param channel The channel to subscribe to. The channel name must start with |
||||
a letter and contain only letters, numbers, dashes, and underscores. |
||||
@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. |
||||
*/ |
||||
+ (void)subscribeToChannelInBackground:(NSString *)channel |
||||
target:(nullable id)target |
||||
selector:(nullable SEL)selector; |
||||
|
||||
/**
|
||||
*Synchronously* unsubscribes the device to a channel of push notifications. |
||||
|
||||
@param channel The channel to unsubscribe from. |
||||
@param error Pointer to an `NSError` that will be set if necessary. |
||||
|
||||
@return Returns whether the unsubscribe succeeded. |
||||
*/ |
||||
+ (BOOL)unsubscribeFromChannel:(NSString *)channel error:(NSError **)error; |
||||
|
||||
/**
|
||||
*Asynchronously* unsubscribes the device from a channel of push notifications. |
||||
|
||||
@param channel The channel to unsubscribe from. |
||||
|
||||
@return The task, that encapsulates the work being done. |
||||
*/ |
||||
+ (BFTask PF_GENERIC(NSNumber *)*)unsubscribeFromChannelInBackground:(NSString *)channel; |
||||
|
||||
/**
|
||||
*Asynchronously* unsubscribes the device from a channel of push notifications and calls the given block. |
||||
|
||||
@param channel The channel to unsubscribe from. |
||||
@param block The block to execute. |
||||
It should have the following argument signature: `^(BOOL succeeded, NSError *error)`. |
||||
*/ |
||||
+ (void)unsubscribeFromChannelInBackground:(NSString *)channel |
||||
block:(nullable PFBooleanResultBlock)block; |
||||
|
||||
/*
|
||||
*Asynchronously* unsubscribes the device from a channel of push notifications and calls the given callback. |
||||
|
||||
@param channel The channel to unsubscribe from. |
||||
@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. |
||||
*/ |
||||
+ (void)unsubscribeFromChannelInBackground:(NSString *)channel |
||||
target:(nullable id)target |
||||
selector:(nullable SEL)selector; |
||||
|
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
@ -0,0 +1,892 @@
|
||||
/**
|
||||
* 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/PFGeoPoint.h> |
||||
#import <Parse/PFObject.h> |
||||
#import <Parse/PFUser.h> |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
/**
|
||||
The `PFQuery` class defines a query that is used to query for `PFObject`s. |
||||
*/ |
||||
@interface PFQuery PF_GENERIC(PFGenericObject : PFObject *) : NSObject<NSCopying> |
||||
|
||||
///--------------------------------------
|
||||
/// @name Blocks
|
||||
///--------------------------------------
|
||||
|
||||
typedef void (^PFQueryArrayResultBlock)(NSArray PF_GENERIC(PFGenericObject) * __nullable objects, NSError * __nullable error); |
||||
|
||||
///--------------------------------------
|
||||
/// @name Creating a Query for a Class
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
Initializes the query with a class name. |
||||
|
||||
@param className The class name. |
||||
*/ |
||||
- (instancetype)initWithClassName:(NSString *)className; |
||||
|
||||
/**
|
||||
Returns a `PFQuery` for a given class. |
||||
|
||||
@param className The class to query on. |
||||
|
||||
@return A `PFQuery` object. |
||||
*/ |
||||
+ (instancetype)queryWithClassName:(NSString *)className; |
||||
|
||||
/**
|
||||
Creates a PFQuery with the constraints given by predicate. |
||||
|
||||
The following types of predicates are supported: |
||||
|
||||
- Simple comparisons such as `=`, `!=`, `<`, `>`, `<=`, `>=`, and `BETWEEN` with a key and a constant. |
||||
- Containment predicates, such as `x IN {1, 2, 3}`. |
||||
- Key-existence predicates, such as `x IN SELF`. |
||||
- BEGINSWITH expressions. |
||||
- Compound predicates with `AND`, `OR`, and `NOT`. |
||||
- SubQueries with `key IN %@`, subquery. |
||||
|
||||
The following types of predicates are NOT supported: |
||||
|
||||
- Aggregate operations, such as `ANY`, `SOME`, `ALL`, or `NONE`. |
||||
- Regular expressions, such as `LIKE`, `MATCHES`, `CONTAINS`, or `ENDSWITH`. |
||||
- Predicates comparing one key to another. |
||||
- Complex predicates with many ORed clauses. |
||||
|
||||
@param className The class to query on. |
||||
@param predicate The predicate to create conditions from. |
||||
*/ |
||||
+ (instancetype)queryWithClassName:(NSString *)className predicate:(nullable NSPredicate *)predicate; |
||||
|
||||
/**
|
||||
The class name to query for. |
||||
*/ |
||||
@property (nonatomic, strong) NSString *parseClassName; |
||||
|
||||
///--------------------------------------
|
||||
/// @name Adding Basic Constraints
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
Make the query include PFObjects that have a reference stored at the provided key. |
||||
|
||||
This has an effect similar to a join. You can use dot notation to specify which fields in |
||||
the included object are also fetch. |
||||
|
||||
@param key The key to load child `PFObject`s for. |
||||
|
||||
@return The same instance of `PFQuery` as the receiver. This allows method chaining. |
||||
*/ |
||||
- (instancetype)includeKey:(NSString *)key; |
||||
|
||||
/**
|
||||
Make the query restrict the fields of the returned `PFObject`s to include only the provided keys. |
||||
|
||||
If this is called multiple times, then all of the keys specified in each of the calls will be included. |
||||
|
||||
@param keys The keys to include in the result. |
||||
|
||||
@return The same instance of `PFQuery` as the receiver. This allows method chaining. |
||||
*/ |
||||
- (instancetype)selectKeys:(NSArray PF_GENERIC(NSString *)*)keys; |
||||
|
||||
/**
|
||||
Add a constraint that requires a particular key exists. |
||||
|
||||
@param key The key that should exist. |
||||
|
||||
@return The same instance of `PFQuery` as the receiver. This allows method chaining. |
||||
*/ |
||||
- (instancetype)whereKeyExists:(NSString *)key; |
||||
|
||||
/**
|
||||
Add a constraint that requires a key not exist. |
||||
|
||||
@param key The key that should not exist. |
||||
|
||||
@return The same instance of `PFQuery` as the receiver. This allows method chaining. |
||||
*/ |
||||
- (instancetype)whereKeyDoesNotExist:(NSString *)key; |
||||
|
||||
/**
|
||||
Add a constraint to the query that requires a particular key's object to be equal to the provided object. |
||||
|
||||
@param key The key to be constrained. |
||||
@param object The object that must be equalled. |
||||
|
||||
@return The same instance of `PFQuery` as the receiver. This allows method chaining. |
||||
*/ |
||||
- (instancetype)whereKey:(NSString *)key equalTo:(id)object; |
||||
|
||||
/**
|
||||
Add a constraint to the query that requires a particular key's object to be less than the provided object. |
||||
|
||||
@param key The key to be constrained. |
||||
@param object The object that provides an upper bound. |
||||
|
||||
@return The same instance of `PFQuery` as the receiver. This allows method chaining. |
||||
*/ |
||||
- (instancetype)whereKey:(NSString *)key lessThan:(id)object; |
||||
|
||||
/**
|
||||
Add a constraint to the query that requires a particular key's object |
||||
to be less than or equal to the provided object. |
||||
|
||||
@param key The key to be constrained. |
||||
@param object The object that must be equalled. |
||||
|
||||
@return The same instance of `PFQuery` as the receiver. This allows method chaining. |
||||
*/ |
||||
- (instancetype)whereKey:(NSString *)key lessThanOrEqualTo:(id)object; |
||||
|
||||
/**
|
||||
Add a constraint to the query that requires a particular key's object |
||||
to be greater than the provided object. |
||||
|
||||
@param key The key to be constrained. |
||||
@param object The object that must be equalled. |
||||
|
||||
@return The same instance of `PFQuery` as the receiver. This allows method chaining. |
||||
*/ |
||||
- (instancetype)whereKey:(NSString *)key greaterThan:(id)object; |
||||
|
||||
/**
|
||||
Add a constraint to the query that requires a particular key's |
||||
object to be greater than or equal to the provided object. |
||||
|
||||
@param key The key to be constrained. |
||||
@param object The object that must be equalled. |
||||
|
||||
@return The same instance of `PFQuery` as the receiver. This allows method chaining. |
||||
*/ |
||||
- (instancetype)whereKey:(NSString *)key greaterThanOrEqualTo:(id)object; |
||||
|
||||
/**
|
||||
Add a constraint to the query that requires a particular key's object |
||||
to be not equal to the provided object. |
||||
|
||||
@param key The key to be constrained. |
||||
@param object The object that must not be equalled. |
||||
|
||||
@return The same instance of `PFQuery` as the receiver. This allows method chaining. |
||||
*/ |
||||
- (instancetype)whereKey:(NSString *)key notEqualTo:(id)object; |
||||
|
||||
/**
|
||||
Add a constraint to the query that requires a particular key's object |
||||
to be contained in the provided array. |
||||
|
||||
@param key The key to be constrained. |
||||
@param array The possible values for the key's object. |
||||
|
||||
@return The same instance of `PFQuery` as the receiver. This allows method chaining. |
||||
*/ |
||||
- (instancetype)whereKey:(NSString *)key containedIn:(NSArray *)array; |
||||
|
||||
/**
|
||||
Add a constraint to the query that requires a particular key's object |
||||
not be contained in the provided array. |
||||
|
||||
@param key The key to be constrained. |
||||
@param array The list of values the key's object should not be. |
||||
|
||||
@return The same instance of `PFQuery` as the receiver. This allows method chaining. |
||||
*/ |
||||
- (instancetype)whereKey:(NSString *)key notContainedIn:(NSArray *)array; |
||||
|
||||
/**
|
||||
Add a constraint to the query that requires a particular key's array |
||||
contains every element of the provided array. |
||||
|
||||
@param key The key to be constrained. |
||||
@param array The array of values to search for. |
||||
|
||||
@return The same instance of `PFQuery` as the receiver. This allows method chaining. |
||||
*/ |
||||
- (instancetype)whereKey:(NSString *)key containsAllObjectsInArray:(NSArray *)array; |
||||
|
||||
///--------------------------------------
|
||||
/// @name Adding Location Constraints
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
Add a constraint to the query that requires a particular key's coordinates (specified via `PFGeoPoint`) |
||||
be near a reference point. |
||||
|
||||
Distance is calculated based on angular distance on a sphere. Results will be sorted by distance |
||||
from reference point. |
||||
|
||||
@param key The key to be constrained. |
||||
@param geopoint The reference point represented as a `PFGeoPoint`. |
||||
|
||||
@return The same instance of `PFQuery` as the receiver. This allows method chaining. |
||||
*/ |
||||
- (instancetype)whereKey:(NSString *)key nearGeoPoint:(PFGeoPoint *)geopoint; |
||||
|
||||
/**
|
||||
Add a constraint to the query that requires a particular key's coordinates (specified via `PFGeoPoint`) |
||||
be near a reference point and within the maximum distance specified (in miles). |
||||
|
||||
Distance is calculated based on a spherical coordinate system. |
||||
Results will be sorted by distance (nearest to farthest) from the reference point. |
||||
|
||||
@param key The key to be constrained. |
||||
@param geopoint The reference point represented as a `PFGeoPoint`. |
||||
@param maxDistance Maximum distance in miles. |
||||
|
||||
@return The same instance of `PFQuery` as the receiver. This allows method chaining. |
||||
*/ |
||||
- (instancetype)whereKey:(NSString *)key |
||||
nearGeoPoint:(PFGeoPoint *)geopoint |
||||
withinMiles:(double)maxDistance; |
||||
|
||||
/**
|
||||
Add a constraint to the query that requires a particular key's coordinates (specified via `PFGeoPoint`) |
||||
be near a reference point and within the maximum distance specified (in kilometers). |
||||
|
||||
Distance is calculated based on a spherical coordinate system. |
||||
Results will be sorted by distance (nearest to farthest) from the reference point. |
||||
|
||||
@param key The key to be constrained. |
||||
@param geopoint The reference point represented as a `PFGeoPoint`. |
||||
@param maxDistance Maximum distance in kilometers. |
||||
|
||||
@return The same instance of `PFQuery` as the receiver. This allows method chaining. |
||||
*/ |
||||
- (instancetype)whereKey:(NSString *)key |
||||
nearGeoPoint:(PFGeoPoint *)geopoint |
||||
withinKilometers:(double)maxDistance; |
||||
|
||||
/**
|
||||
Add a constraint to the query that requires a particular key's coordinates (specified via `PFGeoPoint`) be near |
||||
a reference point and within the maximum distance specified (in radians). Distance is calculated based on |
||||
angular distance on a sphere. Results will be sorted by distance (nearest to farthest) from the reference point. |
||||
|
||||
@param key The key to be constrained. |
||||
@param geopoint The reference point as a `PFGeoPoint`. |
||||
@param maxDistance Maximum distance in radians. |
||||
|
||||
@return The same instance of `PFQuery` as the receiver. This allows method chaining. |
||||
*/ |
||||
- (instancetype)whereKey:(NSString *)key |
||||
nearGeoPoint:(PFGeoPoint *)geopoint |
||||
withinRadians:(double)maxDistance; |
||||
|
||||
/**
|
||||
Add a constraint to the query that requires a particular key's coordinates (specified via `PFGeoPoint`) be |
||||
contained within a given rectangular geographic bounding box. |
||||
|
||||
@param key The key to be constrained. |
||||
@param southwest The lower-left inclusive corner of the box. |
||||
@param northeast The upper-right inclusive corner of the box. |
||||
|
||||
@return The same instance of `PFQuery` as the receiver. This allows method chaining. |
||||
*/ |
||||
- (instancetype)whereKey:(NSString *)key withinGeoBoxFromSouthwest:(PFGeoPoint *)southwest toNortheast:(PFGeoPoint *)northeast; |
||||
|
||||
///--------------------------------------
|
||||
/// @name Adding String Constraints
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
Add a regular expression constraint for finding string values that match the provided regular expression. |
||||
|
||||
@warning This may be slow for large datasets. |
||||
|
||||
@param key The key that the string to match is stored in. |
||||
@param regex The regular expression pattern to match. |
||||
|
||||
@return The same instance of `PFQuery` as the receiver. This allows method chaining. |
||||
*/ |
||||
- (instancetype)whereKey:(NSString *)key matchesRegex:(NSString *)regex; |
||||
|
||||
/**
|
||||
Add a regular expression constraint for finding string values that match the provided regular expression. |
||||
|
||||
@warning This may be slow for large datasets. |
||||
|
||||
@param key The key that the string to match is stored in. |
||||
@param regex The regular expression pattern to match. |
||||
@param modifiers Any of the following supported PCRE modifiers: |
||||
- `i` - Case insensitive search |
||||
- `m` - Search across multiple lines of input |
||||
|
||||
@return The same instance of `PFQuery` as the receiver. This allows method chaining. |
||||
*/ |
||||
- (instancetype)whereKey:(NSString *)key |
||||
matchesRegex:(NSString *)regex |
||||
modifiers:(nullable NSString *)modifiers; |
||||
|
||||
/**
|
||||
Add a constraint for finding string values that contain a provided substring. |
||||
|
||||
@warning This will be slow for large datasets. |
||||
|
||||
@param key The key that the string to match is stored in. |
||||
@param substring The substring that the value must contain. |
||||
|
||||
@return The same instance of `PFQuery` as the receiver. This allows method chaining. |
||||
*/ |
||||
- (instancetype)whereKey:(NSString *)key containsString:(nullable NSString *)substring; |
||||
|
||||
/**
|
||||
Add a constraint for finding string values that start with a provided prefix. |
||||
|
||||
This will use smart indexing, so it will be fast for large datasets. |
||||
|
||||
@param key The key that the string to match is stored in. |
||||
@param prefix The substring that the value must start with. |
||||
|
||||
@return The same instance of `PFQuery` as the receiver. This allows method chaining. |
||||
*/ |
||||
- (instancetype)whereKey:(NSString *)key hasPrefix:(nullable NSString *)prefix; |
||||
|
||||
/**
|
||||
Add a constraint for finding string values that end with a provided suffix. |
||||
|
||||
@warning This will be slow for large datasets. |
||||
|
||||
@param key The key that the string to match is stored in. |
||||
@param suffix The substring that the value must end with. |
||||
|
||||
@return The same instance of `PFQuery` as the receiver. This allows method chaining. |
||||
*/ |
||||
- (instancetype)whereKey:(NSString *)key hasSuffix:(nullable NSString *)suffix; |
||||
|
||||
///--------------------------------------
|
||||
/// @name Adding Subqueries
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
Returns a `PFQuery` that is the `or` of the passed in queries. |
||||
|
||||
@param queries The list of queries to or together. |
||||
|
||||
@return An instance of `PFQuery` that is the `or` of the passed in queries. |
||||
*/ |
||||
+ (instancetype)orQueryWithSubqueries:(NSArray PF_GENERIC(PFQuery *)*)queries; |
||||
|
||||
/**
|
||||
Adds a constraint that requires that a key's value matches a value in another key |
||||
in objects returned by a sub query. |
||||
|
||||
@param key The key that the value is stored. |
||||
@param otherKey The key in objects in the returned by the sub query whose value should match. |
||||
@param query The query to run. |
||||
|
||||
@return The same instance of `PFQuery` as the receiver. This allows method chaining. |
||||
*/ |
||||
- (instancetype)whereKey:(NSString *)key |
||||
matchesKey:(NSString *)otherKey |
||||
inQuery:(PFQuery *)query; |
||||
|
||||
/**
|
||||
Adds a constraint that requires that a key's value `NOT` match a value in another key |
||||
in objects returned by a sub query. |
||||
|
||||
@param key The key that the value is stored. |
||||
@param otherKey The key in objects in the returned by the sub query whose value should match. |
||||
@param query The query to run. |
||||
|
||||
@return The same instance of `PFQuery` as the receiver. This allows method chaining. |
||||
*/ |
||||
- (instancetype)whereKey:(NSString *)key |
||||
doesNotMatchKey:(NSString *)otherKey |
||||
inQuery:(PFQuery *)query; |
||||
|
||||
/**
|
||||
Add a constraint that requires that a key's value matches a `PFQuery` constraint. |
||||
|
||||
@warning This only works where the key's values are `PFObject`s or arrays of `PFObject`s. |
||||
|
||||
@param key The key that the value is stored in |
||||
@param query The query the value should match |
||||
|
||||
@return The same instance of `PFQuery` as the receiver. This allows method chaining. |
||||
*/ |
||||
- (instancetype)whereKey:(NSString *)key matchesQuery:(PFQuery *)query; |
||||
|
||||
/**
|
||||
Add a constraint that requires that a key's value to not match a `PFQuery` constraint. |
||||
|
||||
@warning This only works where the key's values are `PFObject`s or arrays of `PFObject`s. |
||||
|
||||
@param key The key that the value is stored in |
||||
@param query The query the value should not match |
||||
|
||||
@return The same instance of `PFQuery` as the receiver. This allows method chaining. |
||||
*/ |
||||
- (instancetype)whereKey:(NSString *)key doesNotMatchQuery:(PFQuery *)query; |
||||
|
||||
///--------------------------------------
|
||||
/// @name Sorting
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
Sort the results in *ascending* order with the given key. |
||||
|
||||
@param key The key to order by. |
||||
|
||||
@return The same instance of `PFQuery` as the receiver. This allows method chaining. |
||||
*/ |
||||
- (instancetype)orderByAscending:(NSString *)key; |
||||
|
||||
/**
|
||||
Additionally sort in *ascending* order by the given key. |
||||
|
||||
The previous keys provided will precedence over this key. |
||||
|
||||
@param key The key to order by. |
||||
*/ |
||||
- (instancetype)addAscendingOrder:(NSString *)key; |
||||
|
||||
/**
|
||||
Sort the results in *descending* order with the given key. |
||||
|
||||
@param key The key to order by. |
||||
|
||||
@return The same instance of `PFQuery` as the receiver. This allows method chaining. |
||||
*/ |
||||
- (instancetype)orderByDescending:(NSString *)key; |
||||
|
||||
/**
|
||||
Additionally sort in *descending* order by the given key. |
||||
|
||||
The previous keys provided will precedence over this key. |
||||
|
||||
@param key The key to order by. |
||||
*/ |
||||
- (instancetype)addDescendingOrder:(NSString *)key; |
||||
|
||||
/**
|
||||
Sort the results using a given sort descriptor. |
||||
|
||||
@warning If a `sortDescriptor` has custom `selector` or `comparator` - they aren't going to be used. |
||||
|
||||
@param sortDescriptor The `NSSortDescriptor` to use to sort the results of the query. |
||||
|
||||
@return The same instance of `PFQuery` as the receiver. This allows method chaining. |
||||
*/ |
||||
- (instancetype)orderBySortDescriptor:(NSSortDescriptor *)sortDescriptor; |
||||
|
||||
/**
|
||||
Sort the results using a given array of sort descriptors. |
||||
|
||||
@warning If a `sortDescriptor` has custom `selector` or `comparator` - they aren't going to be used. |
||||
|
||||
@param sortDescriptors An array of `NSSortDescriptor` objects to use to sort the results of the query. |
||||
|
||||
@return The same instance of `PFQuery` as the receiver. This allows method chaining. |
||||
*/ |
||||
- (instancetype)orderBySortDescriptors:(nullable NSArray PF_GENERIC(NSSortDescriptor *)*)sortDescriptors; |
||||
|
||||
///--------------------------------------
|
||||
/// @name Getting Objects by ID
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
Returns a `PFObject` with a given class and id. |
||||
|
||||
@param objectClass The class name for the object that is being requested. |
||||
@param objectId The id of the object that is being requested. |
||||
|
||||
@return The `PFObject` if found. Returns `nil` if the object isn't found, or if there was an error. |
||||
*/ |
||||
+ (nullable PFGenericObject)getObjectOfClass:(NSString *)objectClass |
||||
objectId:(NSString *)objectId PF_SWIFT_UNAVAILABLE; |
||||
|
||||
/**
|
||||
Returns a `PFObject` with a given class and id and sets an error if necessary. |
||||
|
||||
@param objectClass The class name for the object that is being requested. |
||||
@param objectId The id of the object that is being requested. |
||||
@param error Pointer to an `NSError` that will be set if necessary. |
||||
|
||||
@return The `PFObject` if found. Returns `nil` if the object isn't found, or if there was an `error`. |
||||
*/ |
||||
+ (nullable PFGenericObject)getObjectOfClass:(NSString *)objectClass |
||||
objectId:(NSString *)objectId |
||||
error:(NSError **)error; |
||||
|
||||
/**
|
||||
Returns a `PFObject` with the given id. |
||||
|
||||
@warning This method mutates the query. |
||||
It will reset limit to `1`, skip to `0` and remove all conditions, leaving only `objectId`. |
||||
|
||||
@param objectId The id of the object that is being requested. |
||||
|
||||
@return The `PFObject` if found. Returns nil if the object isn't found, or if there was an error. |
||||
*/ |
||||
- (nullable PFGenericObject)getObjectWithId:(NSString *)objectId PF_SWIFT_UNAVAILABLE; |
||||
|
||||
/**
|
||||
Returns a `PFObject` with the given id and sets an error if necessary. |
||||
|
||||
@warning This method mutates the query. |
||||
It will reset limit to `1`, skip to `0` and remove all conditions, leaving only `objectId`. |
||||
|
||||
@param objectId The id of the object that is being requested. |
||||
@param error Pointer to an `NSError` that will be set if necessary. |
||||
|
||||
@return The `PFObject` if found. Returns nil if the object isn't found, or if there was an error. |
||||
*/ |
||||
- (nullable PFGenericObject)getObjectWithId:(NSString *)objectId error:(NSError **)error; |
||||
|
||||
/**
|
||||
Gets a `PFObject` asynchronously and calls the given block with the result. |
||||
|
||||
@warning This method mutates the query. |
||||
It will reset limit to `1`, skip to `0` and remove all conditions, leaving only `objectId`. |
||||
|
||||
@param objectId The id of the object that is being requested. |
||||
|
||||
@return The task, that encapsulates the work being done. |
||||
*/ |
||||
- (BFTask PF_GENERIC(PFGenericObject) *)getObjectInBackgroundWithId:(NSString *)objectId; |
||||
|
||||
/**
|
||||
Gets a `PFObject` asynchronously and calls the given block with the result. |
||||
|
||||
@warning This method mutates the query. |
||||
It will reset limit to `1`, skip to `0` and remove all conditions, leaving only `objectId`. |
||||
|
||||
@param objectId The id of the object that is being requested. |
||||
@param block The block to execute. |
||||
The block should have the following argument signature: `^(NSArray *object, NSError *error)` |
||||
*/ |
||||
- (void)getObjectInBackgroundWithId:(NSString *)objectId |
||||
block:(nullable void (^)(PFGenericObject __nullable object, NSError *__nullable error))block; |
||||
|
||||
/*
|
||||
Gets a `PFObject` asynchronously. |
||||
|
||||
This mutates the PFQuery. It will reset limit to `1`, skip to `0` and remove all conditions, leaving only `objectId`. |
||||
|
||||
@param objectId The id of the object being requested. |
||||
@param target The target for the callback selector. |
||||
@param selector The selector for the callback. |
||||
It should have the following signature: `(void)callbackWithResult:(id)result error:(NSError *)error`. |
||||
Result will be `nil` if error is set and vice versa. |
||||
*/ |
||||
- (void)getObjectInBackgroundWithId:(NSString *)objectId |
||||
target:(nullable id)target |
||||
selector:(nullable SEL)selector; |
||||
|
||||
///--------------------------------------
|
||||
/// @name Getting User Objects
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
Returns a `PFUser` with a given id. |
||||
|
||||
@param objectId The id of the object that is being requested. |
||||
|
||||
@return The PFUser if found. Returns nil if the object isn't found, or if there was an error. |
||||
*/ |
||||
+ (nullable PFUser *)getUserObjectWithId:(NSString *)objectId PF_SWIFT_UNAVAILABLE; |
||||
|
||||
/**
|
||||
Returns a PFUser with a given class and id and sets an error if necessary. |
||||
@param objectId The id of the object that is being requested. |
||||
@param error Pointer to an NSError that will be set if necessary. |
||||
@result The PFUser if found. Returns nil if the object isn't found, or if there was an error. |
||||
*/ |
||||
+ (nullable PFUser *)getUserObjectWithId:(NSString *)objectId error:(NSError **)error; |
||||
|
||||
/**
|
||||
@deprecated Please use [PFUser query] instead. |
||||
*/ |
||||
+ (instancetype)queryForUser PARSE_DEPRECATED("Use [PFUser query] instead."); |
||||
|
||||
///--------------------------------------
|
||||
/// @name Getting all Matches for a Query
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
Finds objects *synchronously* based on the constructed query. |
||||
|
||||
@return Returns an array of `PFObject` objects that were found. |
||||
*/ |
||||
- (nullable NSArray PF_GENERIC(PFGenericObject) *)findObjects PF_SWIFT_UNAVAILABLE; |
||||
|
||||
/**
|
||||
Finds objects *synchronously* based on the constructed query and sets an error if there was one. |
||||
|
||||
@param error Pointer to an `NSError` that will be set if necessary. |
||||
|
||||
@return Returns an array of `PFObject` objects that were found. |
||||
*/ |
||||
- (nullable NSArray PF_GENERIC(PFGenericObject) *)findObjects:(NSError **)error; |
||||
|
||||
/**
|
||||
Finds objects *asynchronously* and sets the `NSArray` of `PFObject` objects as a result of the task. |
||||
|
||||
@return The task, that encapsulates the work being done. |
||||
*/ |
||||
- (BFTask PF_GENERIC(NSArray<PFGenericObject> *)*)findObjectsInBackground; |
||||
|
||||
/**
|
||||
Finds objects *asynchronously* and calls the given block with the results. |
||||
|
||||
@param block The block to execute. |
||||
It should have the following argument signature: `^(NSArray *objects, NSError *error)` |
||||
*/ |
||||
- (void)findObjectsInBackgroundWithBlock:(nullable PFQueryArrayResultBlock)block; |
||||
|
||||
/*
|
||||
Finds objects *asynchronously* and calls the given callback with the results. |
||||
|
||||
@param target The object to call the selector on. |
||||
@param selector The selector to call. |
||||
It should have the following signature: `(void)callbackWithResult:(id)result error:(NSError *)error`. |
||||
Result will be `nil` if error is set and vice versa. |
||||
*/ |
||||
- (void)findObjectsInBackgroundWithTarget:(nullable id)target selector:(nullable SEL)selector; |
||||
|
||||
///--------------------------------------
|
||||
/// @name Getting the First Match in a Query
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
Gets an object *synchronously* based on the constructed query. |
||||
|
||||
@warning This method mutates the query. It will reset the limit to `1`. |
||||
|
||||
@return Returns a `PFObject`, or `nil` if none was found. |
||||
*/ |
||||
- (nullable PFGenericObject)getFirstObject PF_SWIFT_UNAVAILABLE; |
||||
|
||||
/**
|
||||
Gets an object *synchronously* based on the constructed query and sets an error if any occurred. |
||||
|
||||
@warning This method mutates the query. It will reset the limit to `1`. |
||||
|
||||
@param error Pointer to an `NSError` that will be set if necessary. |
||||
|
||||
@return Returns a `PFObject`, or `nil` if none was found. |
||||
*/ |
||||
- (nullable PFGenericObject)getFirstObject:(NSError **)error; |
||||
|
||||
/**
|
||||
Gets an object *asynchronously* and sets it as a result of the task. |
||||
|
||||
@warning This method mutates the query. It will reset the limit to `1`. |
||||
|
||||
@return The task, that encapsulates the work being done. |
||||
*/ |
||||
- (BFTask PF_GENERIC(PFGenericObject) *)getFirstObjectInBackground; |
||||
|
||||
/**
|
||||
Gets an object *asynchronously* and calls the given block with the result. |
||||
|
||||
@warning This method mutates the query. It will reset the limit to `1`. |
||||
|
||||
@param block The block to execute. |
||||
It should have the following argument signature: `^(PFObject *object, NSError *error)`. |
||||
`result` will be `nil` if `error` is set OR no object was found matching the query. |
||||
`error` will be `nil` if `result` is set OR if the query succeeded, but found no results. |
||||
*/ |
||||
- (void)getFirstObjectInBackgroundWithBlock:(nullable void (^)(PFGenericObject __nullable object, NSError *__nullable error))block; |
||||
|
||||
/*
|
||||
Gets an object *asynchronously* and calls the given callback with the results. |
||||
|
||||
@warning This method mutates the query. It will reset the limit to `1`. |
||||
|
||||
@param target The object to call the selector on. |
||||
@param selector The selector to call. |
||||
It should have the following signature: `(void)callbackWithResult:(PFObject *)result error:(NSError *)error`. |
||||
`result` will be `nil` if `error` is set OR no object was found matching the query. |
||||
`error` will be `nil` if `result` is set OR if the query succeeded, but found no results. |
||||
*/ |
||||
- (void)getFirstObjectInBackgroundWithTarget:(nullable id)target selector:(nullable SEL)selector; |
||||
|
||||
///--------------------------------------
|
||||
/// @name Counting the Matches in a Query
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
Counts objects *synchronously* based on the constructed query. |
||||
|
||||
@return Returns the number of `PFObject` objects that match the query, or `-1` if there is an error. |
||||
*/ |
||||
- (NSInteger)countObjects PF_SWIFT_UNAVAILABLE; |
||||
|
||||
/**
|
||||
Counts objects *synchronously* based on the constructed query and sets an error if there was one. |
||||
|
||||
@param error Pointer to an `NSError` that will be set if necessary. |
||||
|
||||
@return Returns the number of `PFObject` objects that match the query, or `-1` if there is an error. |
||||
*/ |
||||
- (NSInteger)countObjects:(NSError **)error; |
||||
|
||||
/**
|
||||
Counts objects *asynchronously* and sets `NSNumber` with count as a result of the task. |
||||
|
||||
@return The task, that encapsulates the work being done. |
||||
*/ |
||||
- (BFTask PF_GENERIC(NSNumber *)*)countObjectsInBackground; |
||||
|
||||
/**
|
||||
Counts objects *asynchronously* and calls the given block with the counts. |
||||
|
||||
@param block The block to execute. |
||||
It should have the following argument signature: `^(int count, NSError *error)` |
||||
*/ |
||||
- (void)countObjectsInBackgroundWithBlock:(nullable PFIntegerResultBlock)block; |
||||
|
||||
/*
|
||||
Counts objects *asynchronously* and calls the given callback with the count. |
||||
|
||||
@param target The object to call the selector on. |
||||
@param selector The selector to call. |
||||
It should have the following signature: `(void)callbackWithResult:(NSNumber *)result error:(NSError *)error`. |
||||
*/ |
||||
- (void)countObjectsInBackgroundWithTarget:(nullable id)target selector:(nullable SEL)selector; |
||||
|
||||
///--------------------------------------
|
||||
/// @name Cancelling a Query
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
Cancels the current network request (if any). Ensures that callbacks won't be called. |
||||
*/ |
||||
- (void)cancel; |
||||
|
||||
///--------------------------------------
|
||||
/// @name Paginating Results
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
A limit on the number of objects to return. The default limit is `100`, with a |
||||
maximum of 1000 results being returned at a time. |
||||
|
||||
@warning If you are calling `findObjects` with `limit = 1`, you may find it easier to use `getFirst` instead. |
||||
*/ |
||||
@property (nonatomic, assign) NSInteger limit; |
||||
|
||||
/**
|
||||
The number of objects to skip before returning any. |
||||
*/ |
||||
@property (nonatomic, assign) NSInteger skip; |
||||
|
||||
///--------------------------------------
|
||||
/// @name Controlling Caching Behavior
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
The cache policy to use for requests. |
||||
|
||||
Not allowed when Pinning is enabled. |
||||
|
||||
@see fromLocalDatastore |
||||
@see fromPin |
||||
@see fromPinWithName: |
||||
*/ |
||||
@property (nonatomic, assign) PFCachePolicy cachePolicy; |
||||
|
||||
/**
|
||||
The age after which a cached value will be ignored |
||||
*/ |
||||
@property (nonatomic, assign) NSTimeInterval maxCacheAge; |
||||
|
||||
/**
|
||||
Returns whether there is a cached result for this query. |
||||
|
||||
@result `YES` if there is a cached result for this query, otherwise `NO`. |
||||
*/ |
||||
- (BOOL)hasCachedResult; |
||||
|
||||
/**
|
||||
Clears the cached result for this query. If there is no cached result, this is a noop. |
||||
*/ |
||||
- (void)clearCachedResult; |
||||
|
||||
/**
|
||||
Clears the cached results for all queries. |
||||
*/ |
||||
+ (void)clearAllCachedResults; |
||||
|
||||
///--------------------------------------
|
||||
/// @name Query Source
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
Change the source of this query to all pinned objects. |
||||
|
||||
@warning Requires Local Datastore to be enabled. |
||||
|
||||
@return The same instance of `PFQuery` as the receiver. This allows method chaining. |
||||
|
||||
@see cachePolicy |
||||
*/ |
||||
- (instancetype)fromLocalDatastore; |
||||
|
||||
/**
|
||||
Change the source of this query to the default group of pinned objects. |
||||
|
||||
@warning Requires Local Datastore to be enabled. |
||||
|
||||
@return The same instance of `PFQuery` as the receiver. This allows method chaining. |
||||
|
||||
@see PFObjectDefaultPin |
||||
@see cachePolicy |
||||
*/ |
||||
- (instancetype)fromPin; |
||||
|
||||
/**
|
||||
Change the source of this query to a specific group of pinned objects. |
||||
|
||||
@warning Requires Local Datastore to be enabled. |
||||
|
||||
@param name The pinned group. |
||||
|
||||
@return The same instance of `PFQuery` as the receiver. This allows method chaining. |
||||
|
||||
@see PFObjectDefaultPin |
||||
@see cachePolicy |
||||
*/ |
||||
- (instancetype)fromPinWithName:(nullable NSString *)name; |
||||
|
||||
/**
|
||||
Ignore ACLs when querying from the Local Datastore. |
||||
|
||||
This is particularly useful when querying for objects with Role based ACLs set on them. |
||||
|
||||
@warning Requires Local Datastore to be enabled. |
||||
|
||||
@return The same instance of `PFQuery` as the receiver. This allows method chaining. |
||||
*/ |
||||
- (instancetype)ignoreACLs; |
||||
|
||||
///--------------------------------------
|
||||
/// @name Advanced Settings
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
Whether or not performance tracing should be done on the query. |
||||
|
||||
@warning This should not be set to `YES` in most cases. |
||||
*/ |
||||
@property (nonatomic, assign) BOOL trace; |
||||
|
||||
@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 <Foundation/Foundation.h> |
||||
|
||||
#import <Parse/PFObject.h> |
||||
#import <Parse/PFQuery.h> |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
/**
|
||||
The `PFRelation` class that is used to access all of the children of a many-to-many relationship. |
||||
Each instance of `PFRelation` is associated with a particular parent object and key. |
||||
*/ |
||||
@interface PFRelation : NSObject |
||||
|
||||
/**
|
||||
The name of the class of the target child objects. |
||||
*/ |
||||
@property (nullable, nonatomic, copy) NSString *targetClass; |
||||
|
||||
///--------------------------------------
|
||||
/// @name Accessing Objects
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
Returns a `PFQuery` object that can be used to get objects in this relation. |
||||
*/ |
||||
- (PFQuery *)query; |
||||
|
||||
///--------------------------------------
|
||||
/// @name Modifying Relations
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
Adds a relation to the passed in object. |
||||
|
||||
@param object A `PFObject` object to add relation to. |
||||
*/ |
||||
- (void)addObject:(PFObject *)object; |
||||
|
||||
/**
|
||||
Removes a relation to the passed in object. |
||||
|
||||
@param object A `PFObject` object to add relation to. |
||||
*/ |
||||
- (void)removeObject:(PFObject *)object; |
||||
|
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
@ -0,0 +1,99 @@
|
||||
/**
|
||||
* 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> |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
/**
|
||||
The `PFRole` class represents a Role on the Parse server. |
||||
`PFRoles` represent groupings of `PFUser` objects for the purposes of granting permissions |
||||
(e.g. specifying a `PFACL` for a `PFObject`). |
||||
Roles are specified by their sets of child users and child roles, |
||||
all of which are granted any permissions that the parent role has. |
||||
|
||||
Roles must have a name (which cannot be changed after creation of the role), and must specify an ACL. |
||||
*/ |
||||
@interface PFRole : PFObject <PFSubclassing> |
||||
|
||||
///--------------------------------------
|
||||
/// @name Creating a New Role
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
Constructs a new `PFRole` with the given name. |
||||
If no default ACL has been specified, you must provide an ACL for the role. |
||||
|
||||
@param name The name of the Role to create. |
||||
*/ |
||||
- (instancetype)initWithName:(NSString *)name; |
||||
|
||||
/**
|
||||
Constructs a new `PFRole` with the given name. |
||||
|
||||
@param name The name of the Role to create. |
||||
@param acl The ACL for this role. Roles must have an ACL. |
||||
*/ |
||||
- (instancetype)initWithName:(NSString *)name acl:(nullable PFACL *)acl; |
||||
|
||||
/**
|
||||
Constructs a new `PFRole` with the given name. |
||||
|
||||
If no default ACL has been specified, you must provide an ACL for the role. |
||||
|
||||
@param name The name of the Role to create. |
||||
*/ |
||||
+ (instancetype)roleWithName:(NSString *)name; |
||||
|
||||
/**
|
||||
Constructs a new `PFRole` with the given name. |
||||
|
||||
@param name The name of the Role to create. |
||||
@param acl The ACL for this role. Roles must have an ACL. |
||||
*/ |
||||
+ (instancetype)roleWithName:(NSString *)name acl:(nullable PFACL *)acl; |
||||
|
||||
///--------------------------------------
|
||||
/// @name Role-specific Properties
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
Gets or sets the name for a role. |
||||
|
||||
This value must be set before the role has been saved to the server, |
||||
and cannot be set once the role has been saved. |
||||
|
||||
@warning A role's name can only contain alphanumeric characters, `_`, `-`, and spaces. |
||||
*/ |
||||
@property (nonatomic, copy) NSString *name; |
||||
|
||||
/**
|
||||
Gets the `PFRelation` for the `PFUser` objects that are direct children of this role. |
||||
|
||||
These users are granted any privileges that this role has been granted |
||||
(e.g. read or write access through ACLs). You can add or remove users from |
||||
the role through this relation. |
||||
*/ |
||||
@property (nonatomic, strong, readonly) PFRelation *users; |
||||
|
||||
/**
|
||||
Gets the `PFRelation` for the `PFRole` objects that are direct children of this role. |
||||
|
||||
These roles' users are granted any privileges that this role has been granted |
||||
(e.g. read or write access through ACLs). You can add or remove child roles |
||||
from this role through this relation. |
||||
*/ |
||||
@property (nonatomic, strong, readonly) PFRelation *roles; |
||||
|
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
@ -0,0 +1,52 @@
|
||||
/**
|
||||
* 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/PFObject.h> |
||||
#import <Parse/PFSubclassing.h> |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
@class PFSession; |
||||
|
||||
typedef void(^PFSessionResultBlock)(PFSession *__nullable session, NSError *__nullable error); |
||||
|
||||
/**
|
||||
`PFSession` is a local representation of a session. |
||||
This class is a subclass of a `PFObject`, |
||||
and retains the same functionality as any other subclass of `PFObject`. |
||||
*/ |
||||
@interface PFSession : PFObject<PFSubclassing> |
||||
|
||||
/**
|
||||
The session token string for this session. |
||||
*/ |
||||
@property (nullable, nonatomic, copy, readonly) NSString *sessionToken; |
||||
|
||||
/**
|
||||
*Asynchronously* fetches a `PFSession` object related to the current user. |
||||
|
||||
@return A task that is `completed` with an instance of `PFSession` class or is `faulted` if the operation fails. |
||||
*/ |
||||
+ (BFTask PF_GENERIC(PFSession *)*)getCurrentSessionInBackground; |
||||
|
||||
/**
|
||||
*Asynchronously* fetches a `PFSession` object related to the current user. |
||||
|
||||
@param block The block to execute when the operation completes. |
||||
It should have the following argument signature: `^(PFSession *session, NSError *error)`. |
||||
*/ |
||||
+ (void)getCurrentSessionInBackgroundWithBlock:(nullable PFSessionResultBlock)block; |
||||
|
||||
@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> |
||||
|
||||
@class PFQuery PF_GENERIC(PFGenericObject : PFObject *); |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
/**
|
||||
If a subclass of `PFObject` conforms to `PFSubclassing` and calls `PFObject.+registerSubclass`, |
||||
Parse framework will be able to use that class as the native class for a Parse cloud object. |
||||
|
||||
Classes conforming to this protocol should subclass `PFObject` and |
||||
include `PFObject+Subclass.h` in their implementation file. |
||||
This ensures the methods in the Subclass category of `PFObject` are exposed in its subclasses only. |
||||
*/ |
||||
@protocol PFSubclassing |
||||
|
||||
@required |
||||
|
||||
/**
|
||||
The name of the class as seen in the REST API. |
||||
*/ |
||||
+ (NSString *)parseClassName; |
||||
|
||||
@optional |
||||
|
||||
/**
|
||||
Constructs an object of the most specific class known to implement `+parseClassName`. |
||||
|
||||
This method takes care to help `PFObject` subclasses be subclassed themselves. |
||||
For example, `PFUser.+object` returns a `PFUser` by default but will return an |
||||
object of a registered subclass instead if one is known. |
||||
A default implementation is provided by `PFObject` which should always be sufficient. |
||||
|
||||
@return Returns the object that is instantiated. |
||||
*/ |
||||
+ (instancetype)object; |
||||
|
||||
/**
|
||||
Creates a reference to an existing PFObject for use in creating associations between PFObjects. |
||||
|
||||
Calling `PFObject.dataAvailable` on this object will return `NO` |
||||
until `PFObject.-fetchIfNeeded` has been called. No network request will be made. |
||||
A default implementation is provided by `PFObject` which should always be sufficient. |
||||
|
||||
@param objectId The object id for the referenced object. |
||||
|
||||
@return A new `PFObject` without data. |
||||
*/ |
||||
+ (instancetype)objectWithoutDataWithObjectId:(nullable NSString *)objectId; |
||||
|
||||
/**
|
||||
Create a query which returns objects of this type. |
||||
|
||||
A default implementation is provided by `PFObject` which should always be sufficient. |
||||
*/ |
||||
+ (nullable PFQuery *)query; |
||||
|
||||
/**
|
||||
Returns a query for objects of this type with a given predicate. |
||||
|
||||
A default implementation is provided by `PFObject` which should always be sufficient. |
||||
|
||||
@param predicate The predicate to create conditions from. |
||||
|
||||
@return An instance of `PFQuery`. |
||||
|
||||
@see [PFQuery queryWithClassName:predicate:] |
||||
*/ |
||||
+ (nullable PFQuery *)queryWithPredicate:(nullable NSPredicate *)predicate; |
||||
|
||||
/**
|
||||
Lets Parse know this class should be used to instantiate all objects with class type `parseClassName`. |
||||
|
||||
@warning This method must be called before `Parse.+setApplicationId:clientKey:`. |
||||
*/ |
||||
+ (void)registerSubclass; |
||||
|
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
@ -0,0 +1,519 @@
|
||||
/**
|
||||
* 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/PFObject.h> |
||||
#import <Parse/PFSubclassing.h> |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
typedef void(^PFUserSessionUpgradeResultBlock)(NSError *__nullable error); |
||||
typedef void(^PFUserLogoutResultBlock)(NSError *__nullable error); |
||||
|
||||
@class PFQuery PF_GENERIC(PFGenericObject : PFObject *); |
||||
@protocol PFUserAuthenticationDelegate; |
||||
|
||||
/**
|
||||
The `PFUser` class is a local representation of a user persisted to the Parse Data. |
||||
This class is a subclass of a `PFObject`, and retains the same functionality of a `PFObject`, |
||||
but also extends it with various user specific methods, like authentication, signing up, and validation uniqueness. |
||||
|
||||
Many APIs responsible for linking a `PFUser` with Facebook or Twitter have been deprecated in favor of dedicated |
||||
utilities for each social network. See `PFFacebookUtils`, `PFTwitterUtils` and `PFAnonymousUtils` for more information. |
||||
*/ |
||||
|
||||
@interface PFUser : PFObject <PFSubclassing> |
||||
|
||||
///--------------------------------------
|
||||
/// @name Accessing the Current User
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
Gets the currently logged in user from disk and returns an instance of it. |
||||
|
||||
@return Returns a `PFUser` that is the currently logged in user. If there is none, returns `nil`. |
||||
*/ |
||||
+ (nullable instancetype)currentUser; |
||||
|
||||
/**
|
||||
The session token for the `PFUser`. |
||||
|
||||
This is set by the server upon successful authentication. |
||||
*/ |
||||
@property (nullable, nonatomic, copy, readonly) NSString *sessionToken; |
||||
|
||||
/**
|
||||
Whether the `PFUser` was just created from a request. |
||||
|
||||
This is only set after a Facebook or Twitter login. |
||||
*/ |
||||
@property (nonatomic, assign, readonly) BOOL isNew; |
||||
|
||||
/**
|
||||
Whether the user is an authenticated object for the device. |
||||
|
||||
An authenticated `PFUser` is one that is obtained via a `-signUp:` or `+logInWithUsername:password:` method. |
||||
An authenticated object is required in order to save (with altered values) or delete it. |
||||
*/ |
||||
@property (nonatomic, assign, readonly, getter=isAuthenticated) BOOL authenticated; |
||||
|
||||
///--------------------------------------
|
||||
/// @name Creating a New User
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
Creates a new `PFUser` object. |
||||
|
||||
@return Returns a new `PFUser` object. |
||||
*/ |
||||
+ (instancetype)user; |
||||
|
||||
/**
|
||||
Enables automatic creation of anonymous users. |
||||
|
||||
After calling this method, `+currentUser` will always have a value. |
||||
The user will only be created on the server once the user has been saved, |
||||
or once an object with a relation to that user or an ACL that refers to the user has been saved. |
||||
|
||||
@warning `PFObject.-saveEventually` will not work on if an item being saved has a relation |
||||
to an automatic user that has never been saved. |
||||
*/ |
||||
+ (void)enableAutomaticUser; |
||||
|
||||
/**
|
||||
The username for the `PFUser`. |
||||
*/ |
||||
@property (nullable, nonatomic, strong) NSString *username; |
||||
|
||||
/**!
|
||||
The password for the `PFUser`. |
||||
|
||||
This will not be filled in from the server with the password. |
||||
It is only meant to be set. |
||||
*/ |
||||
@property (nullable, nonatomic, strong) NSString *password; |
||||
|
||||
/**
|
||||
The email for the `PFUser`. |
||||
*/ |
||||
@property (nullable, nonatomic, strong) NSString *email; |
||||
|
||||
/**
|
||||
Signs up the user *synchronously*. |
||||
|
||||
This will also enforce that the username isn't already taken. |
||||
|
||||
@warning Make sure that password and username are set before calling this method. |
||||
|
||||
@return Returns `YES` if the sign up was successful, otherwise `NO`. |
||||
*/ |
||||
- (BOOL)signUp PF_SWIFT_UNAVAILABLE; |
||||
|
||||
/**
|
||||
Signs up the user *synchronously*. |
||||
|
||||
This will also enforce that the username isn't already taken. |
||||
|
||||
@warning Make sure that password and username are set before calling this method. |
||||
|
||||
@param error Error object to set on error. |
||||
|
||||
@return Returns whether the sign up was successful. |
||||
*/ |
||||
- (BOOL)signUp:(NSError **)error; |
||||
|
||||
/**
|
||||
Signs up the user *asynchronously*. |
||||
|
||||
This will also enforce that the username isn't already taken. |
||||
|
||||
@warning Make sure that password and username are set before calling this method. |
||||
|
||||
@return The task, that encapsulates the work being done. |
||||
*/ |
||||
- (BFTask PF_GENERIC(NSNumber *)*)signUpInBackground; |
||||
|
||||
/**
|
||||
Signs up the user *asynchronously*. |
||||
|
||||
This will also enforce that the username isn't already taken. |
||||
|
||||
@warning Make sure that password and username are set before calling this method. |
||||
|
||||
@param block The block to execute. |
||||
It should have the following argument signature: `^(BOOL succeeded, NSError *error)`. |
||||
*/ |
||||
- (void)signUpInBackgroundWithBlock:(nullable PFBooleanResultBlock)block; |
||||
|
||||
/**
|
||||
Signs up the user *asynchronously*. |
||||
|
||||
This will also enforce that the username isn't already taken. |
||||
|
||||
@warning Make sure that password and username are set before calling this method. |
||||
|
||||
@param target Target object for the selector. |
||||
@param selector The selector that will be called when the asynchrounous request is complete. |
||||
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. |
||||
*/ |
||||
- (void)signUpInBackgroundWithTarget:(nullable id)target selector:(nullable SEL)selector; |
||||
|
||||
///--------------------------------------
|
||||
/// @name Logging In
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
Makes a *synchronous* request to login a user with specified credentials. |
||||
|
||||
Returns an instance of the successfully logged in `PFUser`. |
||||
This also caches the user locally so that calls to `+currentUser` will use the latest logged in user. |
||||
|
||||
@param username The username of the user. |
||||
@param password The password of the user. |
||||
|
||||
@return Returns an instance of the `PFUser` on success. |
||||
If login failed for either wrong password or wrong username, returns `nil`. |
||||
*/ |
||||
+ (nullable instancetype)logInWithUsername:(NSString *)username |
||||
password:(NSString *)password PF_SWIFT_UNAVAILABLE; |
||||
|
||||
/**
|
||||
Makes a *synchronous* request to login a user with specified credentials. |
||||
|
||||
Returns an instance of the successfully logged in `PFUser`. |
||||
This also caches the user locally so that calls to `+currentUser` will use the latest logged in user. |
||||
|
||||
@param username The username of the user. |
||||
@param password The password of the user. |
||||
@param error The error object to set on error. |
||||
|
||||
@return Returns an instance of the `PFUser` on success. |
||||
If login failed for either wrong password or wrong username, returns `nil`. |
||||
*/ |
||||
+ (nullable instancetype)logInWithUsername:(NSString *)username |
||||
password:(NSString *)password |
||||
error:(NSError **)error; |
||||
|
||||
/**
|
||||
Makes an *asynchronous* request to login a user with specified credentials. |
||||
|
||||
Returns an instance of the successfully logged in `PFUser`. |
||||
This also caches the user locally so that calls to `+currentUser` will use the latest logged in user. |
||||
|
||||
@param username The username of the user. |
||||
@param password The password of the user. |
||||
|
||||
@return The task, that encapsulates the work being done. |
||||
*/ |
||||
+ (BFTask PF_GENERIC(__kindof PFUser *)*)logInWithUsernameInBackground:(NSString *)username |
||||
password:(NSString *)password; |
||||
|
||||
/**
|
||||
Makes an *asynchronous* request to login a user with specified credentials. |
||||
|
||||
Returns an instance of the successfully logged in `PFUser`. |
||||
This also caches the user locally so that calls to `+currentUser` will use the latest logged in user. |
||||
|
||||
@param username The username of the user. |
||||
@param password The password of the user. |
||||
@param target Target object for the selector. |
||||
@param selector The selector that will be called when the asynchrounous request is complete. |
||||
It should have the following signature: `(void)callbackWithUser:(PFUser *)user error:(NSError *)error`. |
||||
*/ |
||||
+ (void)logInWithUsernameInBackground:(NSString *)username |
||||
password:(NSString *)password |
||||
target:(nullable id)target |
||||
selector:(nullable SEL)selector; |
||||
|
||||
/**
|
||||
Makes an *asynchronous* request to log in a user with specified credentials. |
||||
|
||||
Returns an instance of the successfully logged in `PFUser`. |
||||
This also caches the user locally so that calls to `+currentUser` will use the latest logged in user. |
||||
|
||||
@param username The username of the user. |
||||
@param password The password of the user. |
||||
@param block The block to execute. |
||||
It should have the following argument signature: `^(PFUser *user, NSError *error)`. |
||||
*/ |
||||
+ (void)logInWithUsernameInBackground:(NSString *)username |
||||
password:(NSString *)password |
||||
block:(nullable PFUserResultBlock)block; |
||||
|
||||
///--------------------------------------
|
||||
/// @name Becoming a User
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
Makes a *synchronous* request to become a user with the given session token. |
||||
|
||||
Returns an instance of the successfully logged in `PFUser`. |
||||
This also caches the user locally so that calls to `+currentUser` will use the latest logged in user. |
||||
|
||||
@param sessionToken The session token for the user. |
||||
|
||||
@return Returns an instance of the `PFUser` on success. |
||||
If becoming a user fails due to incorrect token, it returns `nil`. |
||||
*/ |
||||
+ (nullable instancetype)become:(NSString *)sessionToken PF_SWIFT_UNAVAILABLE; |
||||
|
||||
/**
|
||||
Makes a *synchronous* request to become a user with the given session token. |
||||
|
||||
Returns an instance of the successfully logged in `PFUser`. |
||||
This will also cache the user locally so that calls to `+currentUser` will use the latest logged in user. |
||||
|
||||
@param sessionToken The session token for the user. |
||||
@param error The error object to set on error. |
||||
|
||||
@return Returns an instance of the `PFUser` on success. |
||||
If becoming a user fails due to incorrect token, it returns `nil`. |
||||
*/ |
||||
+ (nullable instancetype)become:(NSString *)sessionToken error:(NSError **)error; |
||||
|
||||
/**
|
||||
Makes an *asynchronous* request to become a user with the given session token. |
||||
|
||||
Returns an instance of the successfully logged in `PFUser`. |
||||
This also caches the user locally so that calls to `+currentUser` will use the latest logged in user. |
||||
|
||||
@param sessionToken The session token for the user. |
||||
|
||||
@return The task, that encapsulates the work being done. |
||||
*/ |
||||
+ (BFTask PF_GENERIC(__kindof PFUser *)*)becomeInBackground:(NSString *)sessionToken; |
||||
|
||||
/**
|
||||
Makes an *asynchronous* request to become a user with the given session token. |
||||
|
||||
Returns an instance of the successfully logged in `PFUser`. This also caches the user locally |
||||
so that calls to `+currentUser` will use the latest logged in user. |
||||
|
||||
@param sessionToken The session token for the user. |
||||
@param block The block to execute. |
||||
The block should have the following argument signature: `^(PFUser *user, NSError *error)`. |
||||
*/ |
||||
+ (void)becomeInBackground:(NSString *)sessionToken block:(nullable PFUserResultBlock)block; |
||||
|
||||
/**
|
||||
Makes an *asynchronous* request to become a user with the given session token. |
||||
|
||||
Returns an instance of the successfully logged in `PFUser`. This also caches the user locally |
||||
so that calls to `+currentUser` will use the latest logged in user. |
||||
|
||||
@param sessionToken The session token for the user. |
||||
@param target Target object for the selector. |
||||
@param selector The selector that will be called when the asynchrounous request is complete. |
||||
It should have the following signature: `(void)callbackWithUser:(PFUser *)user error:(NSError *)error`. |
||||
*/ |
||||
+ (void)becomeInBackground:(NSString *)sessionToken |
||||
target:(__nullable id)target |
||||
selector:(__nullable SEL)selector; |
||||
|
||||
///--------------------------------------
|
||||
/// @name Revocable Session
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
Enables revocable sessions and migrates the currentUser session token to use revocable session if needed. |
||||
|
||||
This method is required if you want to use `PFSession` APIs |
||||
and your application's 'Require Revocable Session' setting is turned off on `http://parse.com` app settings.
|
||||
After returned `BFTask` completes - `PFSession` class and APIs will be available for use. |
||||
|
||||
@return An instance of `BFTask` that is completed when revocable |
||||
sessions are enabled and currentUser token is migrated. |
||||
*/ |
||||
+ (BFTask *)enableRevocableSessionInBackground; |
||||
|
||||
/**
|
||||
Enables revocable sessions and upgrades the currentUser session token to use revocable session if needed. |
||||
|
||||
This method is required if you want to use `PFSession` APIs |
||||
and legacy sessions are enabled in your application settings on `http://parse.com/`.
|
||||
After returned `BFTask` completes - `PFSession` class and APIs will be available for use. |
||||
|
||||
@param block Block that will be called when revocable sessions are enabled and currentUser token is migrated. |
||||
*/ |
||||
+ (void)enableRevocableSessionInBackgroundWithBlock:(nullable PFUserSessionUpgradeResultBlock)block; |
||||
|
||||
///--------------------------------------
|
||||
/// @name Logging Out
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
*Synchronously* logs out the currently logged in user on disk. |
||||
*/ |
||||
+ (void)logOut; |
||||
|
||||
/**
|
||||
*Asynchronously* logs out the currently logged in user. |
||||
|
||||
This will also remove the session from disk, log out of linked services |
||||
and all future calls to `+currentUser` will return `nil`. This is preferrable to using `-logOut`, |
||||
unless your code is already running from a background thread. |
||||
|
||||
@return An instance of `BFTask`, that is resolved with `nil` result when logging out completes. |
||||
*/ |
||||
+ (BFTask *)logOutInBackground; |
||||
|
||||
/**
|
||||
*Asynchronously* logs out the currently logged in user. |
||||
|
||||
This will also remove the session from disk, log out of linked services |
||||
and all future calls to `+currentUser` will return `nil`. This is preferrable to using `-logOut`, |
||||
unless your code is already running from a background thread. |
||||
|
||||
@param block A block that will be called when logging out completes or fails. |
||||
*/ |
||||
+ (void)logOutInBackgroundWithBlock:(nullable PFUserLogoutResultBlock)block; |
||||
|
||||
///--------------------------------------
|
||||
/// @name Requesting a Password Reset
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
*Synchronously* Send a password reset request for a specified email. |
||||
|
||||
If a user account exists with that email, an email will be sent to that address |
||||
with instructions on how to reset their password. |
||||
|
||||
@param email Email of the account to send a reset password request. |
||||
|
||||
@return Returns `YES` if the reset email request is successful. `NO` - if no account was found for the email address. |
||||
*/ |
||||
+ (BOOL)requestPasswordResetForEmail:(NSString *)email PF_SWIFT_UNAVAILABLE; |
||||
|
||||
/**
|
||||
*Synchronously* send a password reset request for a specified email and sets an error object. |
||||
|
||||
If a user account exists with that email, an email will be sent to that address |
||||
with instructions on how to reset their password. |
||||
|
||||
@param email Email of the account to send a reset password request. |
||||
@param error Error object to set on error. |
||||
@return Returns `YES` if the reset email request is successful. `NO` - if no account was found for the email address. |
||||
*/ |
||||
+ (BOOL)requestPasswordResetForEmail:(NSString *)email error:(NSError **)error; |
||||
|
||||
/**
|
||||
Send a password reset request asynchronously for a specified email and sets an |
||||
error object. If a user account exists with that email, an email will be sent to |
||||
that address with instructions on how to reset their password. |
||||
@param email Email of the account to send a reset password request. |
||||
@return The task, that encapsulates the work being done. |
||||
*/ |
||||
+ (BFTask PF_GENERIC(NSNumber *)*)requestPasswordResetForEmailInBackground:(NSString *)email; |
||||
|
||||
/**
|
||||
Send a password reset request *asynchronously* for a specified email. |
||||
|
||||
If a user account exists with that email, an email will be sent to that address |
||||
with instructions on how to reset their password. |
||||
|
||||
@param email Email of the account to send a reset password request. |
||||
@param block The block to execute. |
||||
It should have the following argument signature: `^(BOOL succeeded, NSError *error)`. |
||||
*/ |
||||
+ (void)requestPasswordResetForEmailInBackground:(NSString *)email |
||||
block:(nullable PFBooleanResultBlock)block; |
||||
|
||||
/**
|
||||
Send a password reset request *asynchronously* for a specified email and sets an error object. |
||||
|
||||
If a user account exists with that email, an email will be sent to that address |
||||
with instructions on how to reset their password. |
||||
|
||||
@param email Email of the account to send a reset password request. |
||||
@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)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. |
||||
*/ |
||||
+ (void)requestPasswordResetForEmailInBackground:(NSString *)email |
||||
target:(__nullable id)target |
||||
selector:(__nullable SEL)selector; |
||||
|
||||
///--------------------------------------
|
||||
/// @name Third-party Authentication
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
Registers a third party authentication delegate. |
||||
|
||||
@note This method shouldn't be invoked directly unless developing a third party authentication library. |
||||
@see PFUserAuthenticationDelegate |
||||
|
||||
@param delegate The third party authenticaiton delegate to be registered. |
||||
@param authType The name of the type of third party authentication source. |
||||
*/ |
||||
+ (void)registerAuthenticationDelegate:(id<PFUserAuthenticationDelegate>)delegate forAuthType:(NSString *)authType; |
||||
|
||||
/**
|
||||
Logs in a user with third party authentication credentials. |
||||
|
||||
@note This method shouldn't be invoked directly unless developing a third party authentication library. |
||||
@see PFUserAuthenticationDelegate |
||||
|
||||
@param authType The name of the type of third party authentication source. |
||||
@param authData The user credentials of the third party authentication source. |
||||
|
||||
@return A `BFTask` that is resolved to `PFUser` when logging in completes. |
||||
*/ |
||||
+ (BFTask PF_GENERIC(PFUser *)*)logInWithAuthTypeInBackground:(NSString *)authType |
||||
authData:(NSDictionary PF_GENERIC(NSString *, NSString *)*)authData; |
||||
|
||||
/**
|
||||
Links this user to a third party authentication library. |
||||
|
||||
@note This method shouldn't be invoked directly unless developing a third party authentication library. |
||||
@see PFUserAuthenticationDelegate |
||||
|
||||
@param authType The name of the type of third party authentication source. |
||||
@param authData The user credentials of the third party authentication source. |
||||
|
||||
@return A `BFTask` that is resolved to `@YES` if linking succeeds. |
||||
*/ |
||||
- (BFTask PF_GENERIC(NSNumber *)*)linkWithAuthTypeInBackground:(NSString *)authType |
||||
authData:(NSDictionary PF_GENERIC(NSString *, NSString *)*)authData; |
||||
|
||||
/**
|
||||
Unlinks this user from a third party authentication library. |
||||
|
||||
@note This method shouldn't be invoked directly unless developing a third party authentication library. |
||||
@see PFUserAuthenticationDelegate |
||||
|
||||
@param authType The name of the type of third party authentication source. |
||||
|
||||
@return A `BFTask` that is resolved to `@YES` if unlinking succeeds. |
||||
*/ |
||||
- (BFTask PF_GENERIC(NSNumber *)*)unlinkWithAuthTypeInBackground:(NSString *)authType; |
||||
|
||||
/**
|
||||
Indicates whether this user is linked with a third party authentication library of a specific type. |
||||
|
||||
@note This method shouldn't be invoked directly unless developing a third party authentication library. |
||||
@see PFUserAuthenticationDelegate |
||||
|
||||
@param authType The name of the type of third party authentication source. |
||||
|
||||
@return `YES` if the user is linked with a provider, otherwise `NO`. |
||||
*/ |
||||
- (BOOL)isLinkedWithAuthType:(NSString *)authType; |
||||
|
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
@ -0,0 +1,36 @@
|
||||
/**
|
||||
* 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/PFConstants.h> |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
/**
|
||||
Provides a general interface for delegation of third party authentication with `PFUser`s. |
||||
*/ |
||||
@protocol PFUserAuthenticationDelegate <NSObject> |
||||
|
||||
/**
|
||||
Called when restoring third party authentication credentials that have been serialized, |
||||
such as session keys, user id, etc. |
||||
|
||||
@note This method will be executed on a background thread. |
||||
|
||||
@param authData The auth data for the provider. This value may be `nil` when unlinking an account. |
||||
|
||||
@return `YES` - if the `authData` was succesfully synchronized, |
||||
or `NO` if user should not longer be associated because of bad `authData`. |
||||
*/ |
||||
- (BOOL)restoreAuthenticationWithAuthData:(nullable NSDictionary PF_GENERIC(NSString *, NSString *)*)authData; |
||||
|
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
@ -0,0 +1,200 @@
|
||||
/**
|
||||
* 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/PFACL.h> |
||||
#import <Parse/PFAnalytics.h> |
||||
#import <Parse/PFAnonymousUtils.h> |
||||
#import <Parse/PFCloud.h> |
||||
#import <Parse/PFConfig.h> |
||||
#import <Parse/PFConstants.h> |
||||
#import <Parse/PFFile.h> |
||||
#import <Parse/PFGeoPoint.h> |
||||
#import <Parse/PFObject+Subclass.h> |
||||
#import <Parse/PFObject.h> |
||||
#import <Parse/PFQuery.h> |
||||
#import <Parse/PFRelation.h> |
||||
#import <Parse/PFRole.h> |
||||
#import <Parse/PFSession.h> |
||||
#import <Parse/PFSubclassing.h> |
||||
#import <Parse/PFUser.h> |
||||
#import <Parse/PFUserAuthenticationDelegate.h> |
||||
|
||||
#if TARGET_OS_IOS |
||||
|
||||
#import <Parse/PFInstallation.h> |
||||
#import <Parse/PFNetworkActivityIndicatorManager.h> |
||||
#import <Parse/PFPush.h> |
||||
#import <Parse/PFProduct.h> |
||||
#import <Parse/PFPurchase.h> |
||||
|
||||
#elif PF_TARGET_OS_OSX |
||||
|
||||
#import <Parse/PFInstallation.h> |
||||
#import <Parse/PFPush.h> |
||||
|
||||
#elif TARGET_OS_TV |
||||
|
||||
#import <Parse/PFProduct.h> |
||||
#import <Parse/PFPurchase.h> |
||||
|
||||
#endif |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
/**
|
||||
The `Parse` class contains static functions that handle global configuration for the Parse framework. |
||||
*/ |
||||
@interface Parse : NSObject |
||||
|
||||
///--------------------------------------
|
||||
/// @name Connecting to Parse
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
Sets the applicationId and clientKey of your application. |
||||
|
||||
@param applicationId The application id of your Parse application. |
||||
@param clientKey The client key of your Parse application. |
||||
*/ |
||||
+ (void)setApplicationId:(NSString *)applicationId clientKey:(NSString *)clientKey; |
||||
|
||||
/**
|
||||
The current application id that was used to configure Parse framework. |
||||
*/ |
||||
+ (NSString *)getApplicationId; |
||||
|
||||
/**
|
||||
The current client key that was used to configure Parse framework. |
||||
*/ |
||||
+ (NSString *)getClientKey; |
||||
|
||||
///--------------------------------------
|
||||
/// @name Enabling Local Datastore
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
Enable pinning in your application. This must be called before your application can use |
||||
pinning. The recommended way is to call this method before `+setApplicationId:clientKey:`. |
||||
*/ |
||||
+ (void)enableLocalDatastore PF_TV_UNAVAILABLE; |
||||
|
||||
/**
|
||||
Flag that indicates whether Local Datastore is enabled. |
||||
|
||||
@return `YES` if Local Datastore is enabled, otherwise `NO`. |
||||
*/ |
||||
+ (BOOL)isLocalDatastoreEnabled PF_TV_UNAVAILABLE; |
||||
|
||||
///--------------------------------------
|
||||
/// @name Enabling Extensions Data Sharing
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
Enables data sharing with an application group identifier. |
||||
|
||||
After enabling - Local Datastore, `PFUser.+currentUser`, `PFInstallation.+currentInstallation` and all eventually commands |
||||
are going to be available to every application/extension in a group that have the same Parse applicationId. |
||||
|
||||
@warning This method is required to be called before `+setApplicationId:clientKey:`. |
||||
|
||||
@param groupIdentifier Application Group Identifier to share data with. |
||||
*/ |
||||
+ (void)enableDataSharingWithApplicationGroupIdentifier:(NSString *)groupIdentifier PF_EXTENSION_UNAVAILABLE("Use `enableDataSharingWithApplicationGroupIdentifier:containingApplication:`.") PF_WATCH_UNAVAILABLE PF_TV_UNAVAILABLE; |
||||
|
||||
/**
|
||||
Enables data sharing with an application group identifier. |
||||
|
||||
After enabling - Local Datastore, `PFUser.+currentUser`, `PFInstallation.+currentInstallation` and all eventually commands |
||||
are going to be available to every application/extension in a group that have the same Parse applicationId. |
||||
|
||||
@warning This method is required to be called before `+setApplicationId:clientKey:`. |
||||
This method can only be used by application extensions. |
||||
|
||||
@param groupIdentifier Application Group Identifier to share data with. |
||||
@param bundleIdentifier Bundle identifier of the containing application. |
||||
*/ |
||||
+ (void)enableDataSharingWithApplicationGroupIdentifier:(NSString *)groupIdentifier |
||||
containingApplication:(NSString *)bundleIdentifier PF_WATCH_UNAVAILABLE PF_TV_UNAVAILABLE; |
||||
|
||||
/**
|
||||
Application Group Identifier for Data Sharing. |
||||
|
||||
@return `NSString` value if data sharing is enabled, otherwise `nil`. |
||||
*/ |
||||
+ (NSString *)applicationGroupIdentifierForDataSharing PF_WATCH_UNAVAILABLE PF_TV_UNAVAILABLE; |
||||
|
||||
/**
|
||||
Containing application bundle identifier for Data Sharing. |
||||
|
||||
@return `NSString` value if data sharing is enabled, otherwise `nil`. |
||||
*/ |
||||
+ (NSString *)containingApplicationBundleIdentifierForDataSharing PF_WATCH_UNAVAILABLE PF_TV_UNAVAILABLE; |
||||
|
||||
#if PARSE_IOS_ONLY |
||||
|
||||
///--------------------------------------
|
||||
/// @name Configuring UI Settings
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
Set whether to show offline messages when using a Parse view or view controller related classes. |
||||
|
||||
@param enabled Whether a `UIAlertView` should be shown when the device is offline |
||||
and network access is required from a view or view controller. |
||||
|
||||
@deprecated This method has no effect. |
||||
*/ |
||||
+ (void)offlineMessagesEnabled:(BOOL)enabled PARSE_DEPRECATED("This method is deprecated and has no effect."); |
||||
|
||||
/**
|
||||
Set whether to show an error message when using a Parse view or view controller related classes |
||||
and a Parse error was generated via a query. |
||||
|
||||
@param enabled Whether a `UIAlertView` should be shown when an error occurs. |
||||
|
||||
@deprecated This method has no effect. |
||||
*/ |
||||
+ (void)errorMessagesEnabled:(BOOL)enabled PARSE_DEPRECATED("This method is deprecated and has no effect."); |
||||
|
||||
#endif |
||||
|
||||
///--------------------------------------
|
||||
/// @name Logging
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
Sets the level of logging to display. |
||||
|
||||
By default: |
||||
- If running inside an app that was downloaded from iOS App Store - it is set to `PFLogLevelNone` |
||||
- All other cases - it is set to `PFLogLevelWarning` |
||||
|
||||
@param logLevel Log level to set. |
||||
@see PFLogLevel |
||||
*/ |
||||
+ (void)setLogLevel:(PFLogLevel)logLevel; |
||||
|
||||
/**
|
||||
Log level that will be displayed. |
||||
|
||||
By default: |
||||
|
||||
- If running inside an app that was downloaded from iOS App Store - it is set to `PFLogLevelNone` |
||||
- All other cases - it is set to `PFLogLevelWarning` |
||||
|
||||
@return A `PFLogLevel` value. |
||||
@see PFLogLevel |
||||
*/ |
||||
+ (PFLogLevel)logLevel; |
||||
|
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
@ -0,0 +1,6 @@
|
||||
framework module Parse { |
||||
umbrella header "Parse.h" |
||||
|
||||
export * |
||||
module * { export * } |
||||
} |
Binary file not shown.
@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
||||
<plist version="1.0"> |
||||
<dict> |
||||
<key>BuildMachineOSBuild</key> |
||||
<string>15C50</string> |
||||
<key>CFBundleDevelopmentRegion</key> |
||||
<string>English</string> |
||||
<key>CFBundleExecutable</key> |
||||
<string>Parse</string> |
||||
<key>CFBundleIdentifier</key> |
||||
<string>com.parse.osx</string> |
||||
<key>CFBundleInfoDictionaryVersion</key> |
||||
<string>6.0</string> |
||||
<key>CFBundlePackageType</key> |
||||
<string>FMWK</string> |
||||
<key>CFBundleShortVersionString</key> |
||||
<string>1.11.0</string> |
||||
<key>CFBundleSignature</key> |
||||
<string>????</string> |
||||
<key>CFBundleSupportedPlatforms</key> |
||||
<array> |
||||
<string>MacOSX</string> |
||||
</array> |
||||
<key>CFBundleVersion</key> |
||||
<string>1.11.0</string> |
||||
<key>DTCompiler</key> |
||||
<string>com.apple.compilers.llvm.clang.1_0</string> |
||||
<key>DTPlatformBuild</key> |
||||
<string>7C68</string> |
||||
<key>DTPlatformVersion</key> |
||||
<string>GM</string> |
||||
<key>DTSDKBuild</key> |
||||
<string>15C43</string> |
||||
<key>DTSDKName</key> |
||||
<string>macosx10.11</string> |
||||
<key>DTXcode</key> |
||||
<string>0720</string> |
||||
<key>DTXcodeBuild</key> |
||||
<string>7C68</string> |
||||
</dict> |
||||
</plist> |
Binary file not shown.
@ -0,0 +1,68 @@
|
||||
THE FOLLOWING SETS FORTH ATTRIBUTION NOTICES FOR THIRD PARTY SOFTWARE THAT MAY BE CONTAINED IN PORTIONS OF THE PARSE PRODUCT. |
||||
|
||||
----- |
||||
|
||||
The following software may be included in this product: OAuthCore. This software contains the following license and notice below: |
||||
|
||||
Copyright (C) 2012 Loren Brichter |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
|
||||
----- |
||||
|
||||
The following software may be included in this product: google-breakpad. This software contains the following license and notice below: |
||||
|
||||
Copyright (c) 2006, Google Inc. |
||||
All rights reserved. |
||||
|
||||
Redistribution and use in source and binary forms, with or without |
||||
modification, are permitted provided that the following conditions are |
||||
met: |
||||
|
||||
* Redistributions of source code must retain the above copyright |
||||
notice, this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above |
||||
copyright notice, this list of conditions and the following disclaimer |
||||
in the documentation and/or other materials provided with the |
||||
distribution. |
||||
* Neither the name of Google Inc. nor the names of its |
||||
contributors may be used to endorse or promote products derived from |
||||
this software without specific prior written permission. |
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
|
||||
-------------------------------------------------------------------- |
||||
|
||||
Copyright 2001-2004 Unicode, Inc. |
||||
|
||||
Disclaimer |
||||
|
||||
This source code is provided as is by Unicode, Inc. No claims are |
||||
made as to fitness for any particular purpose. No warranties of any |
||||
kind are expressed or implied. The recipient agrees to determine |
||||
applicability of information provided. If this file has been |
||||
purchased on magnetic or optical media from Unicode, Inc., the |
||||
sole remedy for any claim will be exchange of defective media |
||||
within 90 days of receipt. |
||||
|
||||
Limitations on Rights to Redistribute This Code |
||||
|
||||
Unicode, Inc. hereby grants the right to freely use the information |
||||
supplied in this file in the creation of products supporting the |
||||
Unicode Standard, and to make copies of this file in any form |
||||
for internal or external distribution as long as this notice |
||||
remains attached. |
Loading…
Reference in new issue