Skip to content

Commit cf51bc6

Browse files
committed
Merge pull request #65 from ParsePlatform/nlutsenko.annotate
Add nullability annotations to 100% of public API.
2 parents f5d1279 + f45d25a commit cf51bc6

File tree

3 files changed

+39
-28
lines changed

3 files changed

+39
-28
lines changed

Parse/PFPurchase.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@
1111
#import <StoreKit/StoreKit.h>
1212

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

1516
@class PFProduct;
1617

18+
PF_ASSUME_NONNULL_BEGIN
19+
1720
/*!
1821
`PFPurchase` provides a set of APIs for working with in-app purchases.
1922
@@ -65,7 +68,7 @@
6568
*/
6669
+ (void)downloadAssetForTransaction:(SKPaymentTransaction *)transaction
6770
completion:(void(^)(NSString *filePath, NSError *error))completion
68-
progress:(PFProgressBlock)progress;
71+
progress:(PF_NULLABLE PFProgressBlock)progress;
6972

7073
/*!
7174
@abstract *Asynchronously* restore completed transactions for the current user.
@@ -85,6 +88,8 @@
8588
8689
@warning This method will return `nil`, if the purchase wasn't verified or if the asset was not downloaded.
8790
*/
88-
+ (NSString *)assetContentPathForProduct:(PFProduct *)product;
91+
+ (PF_NULLABLE NSString *)assetContentPathForProduct:(PFProduct *)product;
8992

9093
@end
94+
95+
PF_ASSUME_NONNULL_END

Parse/PFPush.h

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
@class PFQuery;
1717

18+
PF_ASSUME_NONNULL_BEGIN
19+
1820
/*!
1921
The `PFPush` class defines a push notification that can be sent from a client device.
2022
@@ -39,15 +41,15 @@
3941
@param channel The channel to set for this push.
4042
The channel name must start with a letter and contain only letters, numbers, dashes, and underscores.
4143
*/
42-
- (void)setChannel:(NSString *)channel;
44+
- (void)setChannel:(PF_NULLABLE NSString *)channel;
4345

4446
/*!
4547
@abstract Sets the array of channels on which this push notification will be sent.
4648
4749
@param channels The array of channels to set for this push.
4850
Each channel name must start with a letter and contain only letters, numbers, dashes, and underscores.
4951
*/
50-
- (void)setChannels:(NSArray *)channels;
52+
- (void)setChannels:(PF_NULLABLE NSArray *)channels;
5153

5254
/*!
5355
@abstract Sets an installation query to which this push notification will be sent.
@@ -56,7 +58,7 @@
5658
5759
@param query The installation query to set for this push.
5860
*/
59-
- (void)setQuery:(PFQuery *)query;
61+
- (void)setQuery:(PF_NULLABLE PFQuery *)query;
6062

6163
/*!
6264
@abstract Sets an alert message for this push notification.
@@ -65,7 +67,7 @@
6567
6668
@param message The message to send in this push.
6769
*/
68-
- (void)setMessage:(NSString *)message;
70+
- (void)setMessage:(PF_NULLABLE NSString *)message;
6971

7072
/*!
7173
@abstract Sets an arbitrary data payload for this push notification.
@@ -76,7 +78,7 @@
7678
7779
@param data The data to send in this push.
7880
*/
79-
- (void)setData:(NSDictionary *)data;
81+
- (void)setData:(PF_NULLABLE NSDictionary *)data;
8082

8183
/*!
8284
@abstract Sets whether this push will go to Android devices.
@@ -108,7 +110,7 @@
108110
109111
@param date The time at which the notification should expire.
110112
*/
111-
- (void)expireAtDate:(NSDate *)date;
113+
- (void)expireAtDate:(PF_NULLABLE NSDate *)date;
112114

113115
/*!
114116
@abstract Sets the time interval after which this notification should expire.
@@ -169,7 +171,7 @@
169171
*/
170172
+ (void)sendPushMessageToChannelInBackground:(NSString *)channel
171173
withMessage:(NSString *)message
172-
block:(PFBooleanResultBlock)block;
174+
block:(PF_NULLABLE PFBooleanResultBlock)block;
173175

174176
/*
175177
@abstract *Asynchronously* send a push message to a channel.
@@ -185,8 +187,8 @@
185187
*/
186188
+ (void)sendPushMessageToChannelInBackground:(NSString *)channel
187189
withMessage:(NSString *)message
188-
target:(id)target
189-
selector:(SEL)selector;
190+
target:(PF_NULLABLE_S id)target
191+
selector:(PF_NULLABLE_S SEL)selector;
190192

191193
/*!
192194
@abstract Send a push message to a query.
@@ -223,7 +225,7 @@
223225
*/
224226
+ (void)sendPushMessageToQueryInBackground:(PFQuery *)query
225227
withMessage:(NSString *)message
226-
block:(PFBooleanResultBlock)block;
228+
block:(PF_NULLABLE PFBooleanResultBlock)block;
227229

228230
/*!
229231
@abstract *Synchronously* send this push message.
@@ -246,7 +248,7 @@
246248
@param block The block to execute.
247249
It should have the following argument signature: `^(BOOL succeeded, NSError *error)`.
248250
*/
249-
- (void)sendPushInBackgroundWithBlock:(PFBooleanResultBlock)block;
251+
- (void)sendPushInBackgroundWithBlock:(PF_NULLABLE PFBooleanResultBlock)block;
250252

251253
/*
252254
@abstract *Asynchronously* send this push message and calls the given callback.
@@ -257,7 +259,7 @@
257259
`error` will be `nil` on success and set if there was an error.
258260
`[result boolValue]` will tell you whether the call succeeded or not.
259261
*/
260-
- (void)sendPushInBackgroundWithTarget:(id)target selector:(SEL)selector;
262+
- (void)sendPushInBackgroundWithTarget:(PF_NULLABLE_S id)target selector:(PF_NULLABLE_S SEL)selector;
261263

262264
/*!
263265
@abstract *Synchronously* send a push message with arbitrary data to a channel.
@@ -302,7 +304,7 @@
302304
*/
303305
+ (void)sendPushDataToChannelInBackground:(NSString *)channel
304306
withData:(NSDictionary *)data
305-
block:(PFBooleanResultBlock)block;
307+
block:(PF_NULLABLE PFBooleanResultBlock)block;
306308

307309
/*
308310
@abstract *Asynchronously* send a push message with arbitrary data to a channel.
@@ -320,8 +322,8 @@
320322
*/
321323
+ (void)sendPushDataToChannelInBackground:(NSString *)channel
322324
withData:(NSDictionary *)data
323-
target:(id)target
324-
selector:(SEL)selector;
325+
target:(PF_NULLABLE_S id)target
326+
selector:(PF_NULLABLE_S SEL)selector;
325327

326328
/*!
327329
@abstract *Synchronously* send a push message with arbitrary data to a query.
@@ -366,7 +368,7 @@
366368
*/
367369
+ (void)sendPushDataToQueryInBackground:(PFQuery *)query
368370
withData:(NSDictionary *)data
369-
block:(PFBooleanResultBlock)block;
371+
block:(PF_NULLABLE PFBooleanResultBlock)block;
370372

371373
///--------------------------------------
372374
/// @name Handling Notifications
@@ -384,7 +386,7 @@
384386
385387
@param userInfo The userInfo dictionary you get in `appplication:didReceiveRemoteNotification:`.
386388
*/
387-
+ (void)handlePush:(NSDictionary *)userInfo NS_AVAILABLE_IOS(3_0);
389+
+ (void)handlePush:(PF_NULLABLE NSDictionary *)userInfo NS_AVAILABLE_IOS(3_0);
388390

389391
///--------------------------------------
390392
/// @name Managing Channel Subscriptions
@@ -407,7 +409,7 @@
407409
408410
@returns Returns an `NSSet` containing all the channel names this device is subscribed to.
409411
*/
410-
+ (NSSet *)getSubscribedChannels:(NSError **)error;
412+
+ (PF_NULLABLE NSSet *)getSubscribedChannels:(NSError **)error;
411413

412414
/*!
413415
@abstract *Asynchronously* get all the channels that this device is subscribed to.
@@ -464,7 +466,7 @@
464466
It should have the following argument signature: `^(BOOL succeeded, NSError *error)`
465467
*/
466468
+ (void)subscribeToChannelInBackground:(NSString *)channel
467-
block:(PFBooleanResultBlock)block;
469+
block:(PF_NULLABLE PFBooleanResultBlock)block;
468470

469471
/*
470472
@abstract *Asynchronously* subscribes the device to a channel of push notifications and calls the given callback.
@@ -478,8 +480,8 @@
478480
`[result boolValue]` will tell you whether the call succeeded or not.
479481
*/
480482
+ (void)subscribeToChannelInBackground:(NSString *)channel
481-
target:(id)target
482-
selector:(SEL)selector;
483+
target:(PF_NULLABLE_S id)target
484+
selector:(PF_NULLABLE_S SEL)selector;
483485

484486
/*!
485487
@abstract *Synchronously* unsubscribes the device to a channel of push notifications.
@@ -508,7 +510,7 @@
508510
It should have the following argument signature: `^(BOOL succeeded, NSError *error)`.
509511
*/
510512
+ (void)unsubscribeFromChannelInBackground:(NSString *)channel
511-
block:(PFBooleanResultBlock)block;
513+
block:(PF_NULLABLE PFBooleanResultBlock)block;
512514

513515
/*
514516
@abstract *Asynchronously* unsubscribes the device from a channel of push notifications and calls the given callback.
@@ -521,7 +523,9 @@
521523
`[result boolValue]` will tell you whether the call succeeded or not.
522524
*/
523525
+ (void)unsubscribeFromChannelInBackground:(NSString *)channel
524-
target:(id)target
525-
selector:(SEL)selector;
526+
target:(PF_NULLABLE_S id)target
527+
selector:(PF_NULLABLE_S SEL)selector;
526528

527529
@end
530+
531+
PF_ASSUME_NONNULL_END

Tests/Unit/PurchaseUnitTests.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,21 +153,23 @@ - (void)testAssetContentPath {
153153
PFPurchaseController *mockedPurchaseController = [self mockedPurchaseController];
154154
[Parse _currentManager].purchaseController = mockedPurchaseController;
155155

156+
PFProduct *product = [PFProduct object];
157+
156158
NSString *somePath = [NSTemporaryDirectory() stringByAppendingPathComponent:[[NSUUID UUID] UUIDString]];
157159

158160
OCMStub([mockedPurchaseController assetContentPathForProductWithIdentifier:OCMOCK_ANY
159161
fileName:OCMOCK_ANY]).andReturn(somePath);
160162

161163

162-
XCTAssertNil([PFPurchase assetContentPathForProduct:nil]);
164+
XCTAssertNil([PFPurchase assetContentPathForProduct:product]);
163165

164166
NSError *error;
165167
[@"" writeToFile:somePath atomically:YES
166168
encoding:NSUTF8StringEncoding
167169
error:&error];
168170

169171
XCTAssertNil(error);
170-
XCTAssertNotNil([PFPurchase assetContentPathForProduct:nil]);
172+
XCTAssertNotNil([PFPurchase assetContentPathForProduct:product]);
171173
}
172174

173175
@end

0 commit comments

Comments
 (0)