Skip to content

Commit 2e899eb

Browse files
committed
Merge pull request #162 from ParsePlatform/nlutsenko.swift2
Make all synchronous APIs have 'throws' in Swift 2.
2 parents 38b46de + f5f848a commit 2e899eb

File tree

9 files changed

+53
-37
lines changed

9 files changed

+53
-37
lines changed

Parse/PFCloud.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ PF_ASSUME_NONNULL_BEGIN
2828
2929
@returns The response from the cloud function.
3030
*/
31-
+ (PF_NULLABLE_S id)callFunction:(NSString *)function withParameters:(PF_NULLABLE NSDictionary *)parameters;
31+
+ (PF_NULLABLE_S id)callFunction:(NSString *)function
32+
withParameters:(PF_NULLABLE NSDictionary *)parameters PF_SWIFT_UNAVAILABLE;
3233

3334
/*!
3435
@abstract Calls the given cloud function *synchronously* with the parameters provided and

Parse/PFConfig.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#import <Bolts/BFTask.h>
1313

14+
#import <Parse/PFConstants.h>
1415
#import <Parse/PFNullability.h>
1516

1617
PF_ASSUME_NONNULL_BEGIN
@@ -47,7 +48,7 @@ typedef void(^PFConfigResultBlock)(PFConfig *PF_NULLABLE_S config, NSError *PF_N
4748
4849
@returns Instance of `PFConfig` if the operation succeeded, otherwise `nil`.
4950
*/
50-
+ (PF_NULLABLE PFConfig *)getConfig;
51+
+ (PF_NULLABLE PFConfig *)getConfig PF_SWIFT_UNAVAILABLE;
5152

5253
/*!
5354
@abstract Gets the `PFConfig` object *synchronously* from the server and sets an error if it occurs.

Parse/PFConstants.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,3 +420,15 @@ typedef void (^PFProgressBlock)(int percentDone);
420420
# endif
421421
# endif
422422
#endif
423+
424+
///--------------------------------------
425+
/// @name Swift Macros
426+
///--------------------------------------
427+
428+
#ifndef PF_SWIFT_UNAVAILABLE
429+
# ifdef NS_SWIFT_UNAVAILABLE
430+
# define PF_SWIFT_UNAVAILABLE NS_SWIFT_UNAVAILABLE("")
431+
# else
432+
# define PF_SWIFT_UNAVAILABLE
433+
# endif
434+
#endif

Parse/PFFile.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ PF_ASSUME_NONNULL_BEGIN
146146
147147
@returns Returns whether the save succeeded.
148148
*/
149-
- (BOOL)save;
149+
- (BOOL)save PF_SWIFT_UNAVAILABLE;
150150

151151
/*!
152152
@abstract Saves the file *synchronously* and sets an error if it occurs.
@@ -217,7 +217,7 @@ PF_ASSUME_NONNULL_BEGIN
217217
218218
@returns The `NSData` object containing file data. Returns `nil` if there was an error in fetching.
219219
*/
220-
- (PF_NULLABLE NSData *)getData;
220+
- (PF_NULLABLE NSData *)getData PF_SWIFT_UNAVAILABLE;
221221

222222
/*!
223223
@abstract This method is like <getData> but avoids ever holding the entire `PFFile` contents in memory at once.
@@ -226,7 +226,7 @@ PF_ASSUME_NONNULL_BEGIN
226226
227227
@returns A stream containing the data. Returns `nil` if there was an error in fetching.
228228
*/
229-
- (PF_NULLABLE NSInputStream *)getDataStream;
229+
- (PF_NULLABLE NSInputStream *)getDataStream PF_SWIFT_UNAVAILABLE;
230230

231231
/*!
232232
@abstract *Synchronously* gets the data from cache if available or fetches its contents from the network.

Parse/PFObject.h

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ NS_REQUIRES_PROPERTY_DEFINITIONS
300300
301301
@returns Returns whether the save succeeded.
302302
*/
303-
- (BOOL)save;
303+
- (BOOL)save PF_SWIFT_UNAVAILABLE;
304304

305305
/*!
306306
@abstract *Synchronously* saves the `PFObject` and sets an error if it occurs.
@@ -387,7 +387,7 @@ NS_REQUIRES_PROPERTY_DEFINITIONS
387387
388388
@returns Returns whether the save succeeded.
389389
*/
390-
+ (BOOL)saveAll:(PF_NULLABLE NSArray *)objects;
390+
+ (BOOL)saveAll:(PF_NULLABLE NSArray *)objects PF_SWIFT_UNAVAILABLE;
391391

392392
/*!
393393
@abstract Saves a collection of objects *synchronously* all at once and sets an error if necessary.
@@ -443,7 +443,7 @@ NS_REQUIRES_PROPERTY_DEFINITIONS
443443
444444
@returns Returns whether the delete succeeded.
445445
*/
446-
+ (BOOL)deleteAll:(PF_NULLABLE NSArray *)objects;
446+
+ (BOOL)deleteAll:(PF_NULLABLE NSArray *)objects PF_SWIFT_UNAVAILABLE;
447447

448448
/*!
449449
@abstract *Synchronously* deletes a collection of objects all at once and sets an error if necessary.
@@ -504,7 +504,7 @@ NS_REQUIRES_PROPERTY_DEFINITIONS
504504
505505
@deprecated Please use `-fetch` instead.
506506
*/
507-
- (instancetype)refresh PARSE_DEPRECATED("Please use `-fetch` instead.");
507+
- (instancetype)refresh PF_SWIFT_UNAVAILABLE PARSE_DEPRECATED("Please use `-fetch` instead.");
508508

509509
/*!
510510
@abstract *Synchronously* refreshes the `PFObject` with the current data from the server and sets an error if it occurs.
@@ -544,7 +544,7 @@ NS_REQUIRES_PROPERTY_DEFINITIONS
544544
/*!
545545
@abstract *Synchronously* fetches the PFObject with the current data from the server.
546546
*/
547-
- (instancetype)fetch;
547+
- (instancetype)fetch PF_SWIFT_UNAVAILABLE;
548548
/*!
549549
@abstract *Synchronously* fetches the PFObject with the current data from the server and sets an error if it occurs.
550550
@@ -555,7 +555,7 @@ NS_REQUIRES_PROPERTY_DEFINITIONS
555555
/*!
556556
@abstract *Synchronously* fetches the `PFObject` data from the server if <isDataAvailable> is `NO`.
557557
*/
558-
- (PF_NULLABLE PFObject *)fetchIfNeeded;
558+
- (PF_NULLABLE PFObject *)fetchIfNeeded PF_SWIFT_UNAVAILABLE;
559559

560560
/*!
561561
@abstract *Synchronously* fetches the `PFObject` data from the server if <isDataAvailable> is `NO`.
@@ -627,7 +627,7 @@ NS_REQUIRES_PROPERTY_DEFINITIONS
627627
628628
@param objects The list of objects to fetch.
629629
*/
630-
+ (NSArray *)fetchAll:(PF_NULLABLE NSArray *)objects;
630+
+ (NSArray *)fetchAll:(PF_NULLABLE NSArray *)objects PF_SWIFT_UNAVAILABLE;
631631

632632
/*!
633633
@abstract *Synchronously* fetches all of the `PFObject` objects with the current data from the server
@@ -642,7 +642,7 @@ NS_REQUIRES_PROPERTY_DEFINITIONS
642642
@abstract *Synchronously* fetches all of the `PFObject` objects with the current data from the server.
643643
@param objects The list of objects to fetch.
644644
*/
645-
+ (NSArray *)fetchAllIfNeeded:(PF_NULLABLE NSArray *)objects;
645+
+ (NSArray *)fetchAllIfNeeded:(PF_NULLABLE NSArray *)objects PF_SWIFT_UNAVAILABLE;
646646

647647
/*!
648648
@abstract *Synchronously* fetches all of the `PFObject` objects with the current data from the server
@@ -731,7 +731,7 @@ NS_REQUIRES_PROPERTY_DEFINITIONS
731731
@abstract *Synchronously* loads data from the local datastore into this object,
732732
if it has not been fetched from the server already.
733733
*/
734-
- (instancetype)fetchFromLocalDatastore;
734+
- (instancetype)fetchFromLocalDatastore PF_SWIFT_UNAVAILABLE;
735735

736736
/*!
737737
@abstract *Synchronously* loads data from the local datastore into this object, if it has not been fetched
@@ -770,7 +770,7 @@ NS_REQUIRES_PROPERTY_DEFINITIONS
770770
771771
@returns Returns whether the delete succeeded.
772772
*/
773-
- (BOOL)delete;
773+
- (BOOL)delete PF_SWIFT_UNAVAILABLE;
774774

775775
/*!
776776
@abstract *Synchronously* deletes the `PFObject` and sets an error if it occurs.
@@ -867,7 +867,7 @@ NS_REQUIRES_PROPERTY_DEFINITIONS
867867
@see unpin:
868868
@see PFObjectDefaultPin
869869
*/
870-
- (BOOL)pin;
870+
- (BOOL)pin PF_SWIFT_UNAVAILABLE;
871871

872872
/*!
873873
@abstract *Synchronously* stores the object and every object it points to in the local datastore, recursively,
@@ -901,7 +901,7 @@ NS_REQUIRES_PROPERTY_DEFINITIONS
901901
902902
@see unpinWithName:
903903
*/
904-
- (BOOL)pinWithName:(NSString *)name;
904+
- (BOOL)pinWithName:(NSString *)name PF_SWIFT_UNAVAILABLE;
905905

906906
/*!
907907
@abstract *Synchronously* stores the object and every object it points to in the local datastore, recursively.
@@ -1006,7 +1006,7 @@ NS_REQUIRES_PROPERTY_DEFINITIONS
10061006
@see unpinAll:
10071007
@see PFObjectDefaultPin
10081008
*/
1009-
+ (BOOL)pinAll:(PF_NULLABLE NSArray *)objects;
1009+
+ (BOOL)pinAll:(PF_NULLABLE NSArray *)objects PF_SWIFT_UNAVAILABLE;
10101010

10111011
/*!
10121012
@abstract *Synchronously* stores the objects and every object they point to in the local datastore, recursively,
@@ -1042,7 +1042,7 @@ NS_REQUIRES_PROPERTY_DEFINITIONS
10421042
10431043
@see unpinAll:withName:
10441044
*/
1045-
+ (BOOL)pinAll:(PF_NULLABLE NSArray *)objects withName:(NSString *)name;
1045+
+ (BOOL)pinAll:(PF_NULLABLE NSArray *)objects withName:(NSString *)name PF_SWIFT_UNAVAILABLE;
10461046

10471047
/*!
10481048
@abstract *Synchronously* stores the objects and every object they point to in the local datastore, recursively.
@@ -1149,7 +1149,7 @@ NS_REQUIRES_PROPERTY_DEFINITIONS
11491149
@see pin:
11501150
@see PFObjectDefaultPin
11511151
*/
1152-
- (BOOL)unpin;
1152+
- (BOOL)unpin PF_SWIFT_UNAVAILABLE;
11531153

11541154
/*!
11551155
@abstract *Synchronously* removes the object and every object it points to in the local datastore, recursively,
@@ -1173,7 +1173,7 @@ NS_REQUIRES_PROPERTY_DEFINITIONS
11731173
11741174
@see pinWithName:
11751175
*/
1176-
- (BOOL)unpinWithName:(NSString *)name;
1176+
- (BOOL)unpinWithName:(NSString *)name PF_SWIFT_UNAVAILABLE;
11771177

11781178
/*!
11791179
@abstract *Synchronously* removes the object and every object it points to in the local datastore, recursively.
@@ -1245,7 +1245,7 @@ NS_REQUIRES_PROPERTY_DEFINITIONS
12451245
12461246
@see PFObjectDefaultPin
12471247
*/
1248-
+ (BOOL)unpinAllObjects;
1248+
+ (BOOL)unpinAllObjects PF_SWIFT_UNAVAILABLE;
12491249

12501250
/*!
12511251
@abstract *Synchronously* removes all objects in the local datastore
@@ -1266,7 +1266,7 @@ NS_REQUIRES_PROPERTY_DEFINITIONS
12661266
12671267
@returns Returns whether the unpin succeeded.
12681268
*/
1269-
+ (BOOL)unpinAllObjectsWithName:(NSString *)name;
1269+
+ (BOOL)unpinAllObjectsWithName:(NSString *)name PF_SWIFT_UNAVAILABLE;
12701270

12711271
/*!
12721272
@abstract *Synchronously* removes all objects with the specified pin name.
@@ -1329,7 +1329,7 @@ NS_REQUIRES_PROPERTY_DEFINITIONS
13291329
@see pinAll:
13301330
@see PFObjectDefaultPin
13311331
*/
1332-
+ (BOOL)unpinAll:(PF_NULLABLE NSArray *)objects;
1332+
+ (BOOL)unpinAll:(PF_NULLABLE NSArray *)objects PF_SWIFT_UNAVAILABLE;
13331333

13341334
/*!
13351335
@abstract *Synchronously* removes the objects and every object they point to in the local datastore, recursively,
@@ -1355,7 +1355,7 @@ NS_REQUIRES_PROPERTY_DEFINITIONS
13551355
13561356
@see pinAll:withName:
13571357
*/
1358-
+ (BOOL)unpinAll:(PF_NULLABLE NSArray *)objects withName:(NSString *)name;
1358+
+ (BOOL)unpinAll:(PF_NULLABLE NSArray *)objects withName:(NSString *)name PF_SWIFT_UNAVAILABLE;
13591359

13601360
/*!
13611361
@abstract *Synchronously* removes the objects and every object they point to in the local datastore, recursively.

Parse/PFQuery.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ PF_ASSUME_NONNULL_BEGIN
501501
502502
@returns The <PFObject> if found. Returns `nil` if the object isn't found, or if there was an error.
503503
*/
504-
+ (PF_NULLABLE PFObject *)getObjectOfClass:(NSString *)objectClass objectId:(NSString *)objectId;
504+
+ (PF_NULLABLE PFObject *)getObjectOfClass:(NSString *)objectClass objectId:(NSString *)objectId PF_SWIFT_UNAVAILABLE;
505505

506506
/*!
507507
@abstract Returns a <PFObject> with a given class and id and sets an error if necessary.
@@ -526,7 +526,7 @@ PF_ASSUME_NONNULL_BEGIN
526526
527527
@returns The <PFObject> if found. Returns nil if the object isn't found, or if there was an error.
528528
*/
529-
- (PF_NULLABLE PFObject *)getObjectWithId:(NSString *)objectId;
529+
- (PF_NULLABLE PFObject *)getObjectWithId:(NSString *)objectId PF_SWIFT_UNAVAILABLE;
530530

531531
/*!
532532
@abstract Returns a <PFObject> with the given id and sets an error if necessary.
@@ -592,7 +592,7 @@ PF_ASSUME_NONNULL_BEGIN
592592
593593
@returns The PFUser if found. Returns nil if the object isn't found, or if there was an error.
594594
*/
595-
+ (PF_NULLABLE PFUser *)getUserObjectWithId:(NSString *)objectId;
595+
+ (PF_NULLABLE PFUser *)getUserObjectWithId:(NSString *)objectId PF_SWIFT_UNAVAILABLE;
596596

597597
/*!
598598
Returns a PFUser with a given class and id and sets an error if necessary.
@@ -617,7 +617,7 @@ PF_ASSUME_NONNULL_BEGIN
617617
618618
@returns Returns an array of <PFObject> objects that were found.
619619
*/
620-
- (PF_NULLABLE NSArray *)findObjects;
620+
- (PF_NULLABLE NSArray *)findObjects PF_SWIFT_UNAVAILABLE;
621621

622622
/*!
623623
@abstract Finds objects *synchronously* based on the constructed query and sets an error if there was one.
@@ -664,7 +664,7 @@ PF_ASSUME_NONNULL_BEGIN
664664
665665
@returns Returns a <PFObject>, or `nil` if none was found.
666666
*/
667-
- (PF_NULLABLE PFObject *)getFirstObject;
667+
- (PF_NULLABLE PFObject *)getFirstObject PF_SWIFT_UNAVAILABLE;
668668

669669
/*!
670670
@abstract Gets an object *synchronously* based on the constructed query and sets an error if any occurred.
@@ -720,7 +720,7 @@ PF_ASSUME_NONNULL_BEGIN
720720
721721
@returns Returns the number of <PFObject> objects that match the query, or `-1` if there is an error.
722722
*/
723-
- (NSInteger)countObjects;
723+
- (NSInteger)countObjects PF_SWIFT_UNAVAILABLE;
724724

725725
/*!
726726
@abstract Counts objects *synchronously* based on the constructed query and sets an error if there was one.

Parse/PFUser.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ typedef void(^PFUserLogoutResultBlock)(NSError *PF_NULLABLE_S error);
119119
120120
@returns Returns `YES` if the sign up was successful, otherwise `NO`.
121121
*/
122-
- (BOOL)signUp;
122+
- (BOOL)signUp PF_SWIFT_UNAVAILABLE;
123123

124124
/*!
125125
@abstract Signs up the user *synchronously*.
@@ -189,7 +189,7 @@ typedef void(^PFUserLogoutResultBlock)(NSError *PF_NULLABLE_S error);
189189
If login failed for either wrong password or wrong username, returns `nil`.
190190
*/
191191
+ (PF_NULLABLE instancetype)logInWithUsername:(NSString *)username
192-
password:(NSString *)password;
192+
password:(NSString *)password PF_SWIFT_UNAVAILABLE;
193193

194194
/*!
195195
@abstract Makes a *synchronous* request to login a user with specified credentials.
@@ -269,7 +269,7 @@ typedef void(^PFUserLogoutResultBlock)(NSError *PF_NULLABLE_S error);
269269
@returns Returns an instance of the `PFUser` on success.
270270
If becoming a user fails due to incorrect token, it returns `nil`.
271271
*/
272-
+ (PF_NULLABLE instancetype)become:(NSString *)sessionToken;
272+
+ (PF_NULLABLE instancetype)become:(NSString *)sessionToken PF_SWIFT_UNAVAILABLE;
273273

274274
/*!
275275
@abstract Makes a *synchronous* request to become a user with the given session token.
@@ -396,7 +396,7 @@ typedef void(^PFUserLogoutResultBlock)(NSError *PF_NULLABLE_S error);
396396
397397
@returns Returns `YES` if the reset email request is successful. `NO` - if no account was found for the email address.
398398
*/
399-
+ (BOOL)requestPasswordResetForEmail:(NSString *)email;
399+
+ (BOOL)requestPasswordResetForEmail:(NSString *)email PF_SWIFT_UNAVAILABLE;
400400

401401
/*!
402402
@abstract *Synchronously* send a password reset request for a specified email and sets an error object.
@@ -408,8 +408,7 @@ typedef void(^PFUserLogoutResultBlock)(NSError *PF_NULLABLE_S error);
408408
@param error Error object to set on error.
409409
@returns Returns `YES` if the reset email request is successful. `NO` - if no account was found for the email address.
410410
*/
411-
+ (BOOL)requestPasswordResetForEmail:(NSString *)email
412-
error:(NSError **)error;
411+
+ (BOOL)requestPasswordResetForEmail:(NSString *)email error:(NSError **)error;
413412

414413
/*!
415414
@abstract Send a password reset request asynchronously for a specified email and sets an

ParseStarterProject/OSX/ParseOSXStarterProject-Swift/ParseOSXStarterProject-Swift.xcodeproj/project.pbxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@
152152
81CC85B01A49F2E00076DE19 /* Project object */ = {
153153
isa = PBXProject;
154154
attributes = {
155+
LastSwiftUpdateCheck = 0700;
155156
LastUpgradeCheck = 0610;
156157
ORGANIZATIONNAME = Parse;
157158
TargetAttributes = {

ParseStarterProject/iOS/ParseStarterProject-Swift/ParseStarterProject-Swift.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@
167167
81BA813D1A49DA1800E65899 /* Project object */ = {
168168
isa = PBXProject;
169169
attributes = {
170+
LastSwiftUpdateCheck = 0700;
170171
LastUpgradeCheck = 0610;
171172
ORGANIZATIONNAME = Parse;
172173
TargetAttributes = {
@@ -405,6 +406,7 @@
405406
81993FC91B69AA950077D6B9 /* Release */,
406407
);
407408
defaultConfigurationIsVisible = 0;
409+
defaultConfigurationName = Release;
408410
};
409411
81BA81401A49DA1800E65899 /* Build configuration list for PBXProject "ParseStarterProject-Swift" */ = {
410412
isa = XCConfigurationList;

0 commit comments

Comments
 (0)