-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPFObject.h
More file actions
1423 lines (1057 loc) · 50.6 KB
/
PFObject.h
File metadata and controls
1423 lines (1057 loc) · 50.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//
// PFObject.h
//
// Copyright 2011-present Parse Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#if TARGET_OS_IPHONE
#import <Parse/PFACL.h>
#import <Parse/PFConstants.h>
#else
#import <ParseOSX/PFACL.h>
#import <ParseOSX/PFConstants.h>
#endif
PF_ASSUME_NONNULL_BEGIN
@protocol PFSubclassing;
@class BFTask;
@class PFRelation;
/*!
The name of the default pin that for PFObject local data store.
*/
extern NSString *const PFObjectDefaultPin;
/*!
The `PFObject` class is a local representation of data persisted to the Parse cloud.
This is the main class that is used to interact with objects in your app.
*/
NS_REQUIRES_PROPERTY_DEFINITIONS
@interface PFObject : NSObject {
BOOL dirty;
// An array of NSDictionary of NSString -> PFFieldOperation.
// Each dictionary has a subset of the object's keys as keys, and the
// changes to the value for that key as its value.
// There is always at least one dictionary of pending operations.
// Every time a save is started, a new dictionary is added to the end.
// Whenever a save completes, the new data is put into fetchedData, and
// a dictionary is removed from the start.
NSMutableArray *PF_NULLABLE_S operationSetQueue;
// Our best estimate as to what the current data is, based on
// the last fetch from the server, and the set of pending operations.
NSMutableDictionary *PF_NULLABLE_S estimatedData;
}
///--------------------------------------
/// @name Creating a PFObject
///--------------------------------------
/*!
@abstract Creates a new PFObject with a class name.
@param className A class name can be any alphanumeric string that begins with a letter.
It represents an object in your app, like a 'User' or a 'Document'.
@returns Returns the object that is instantiated with the given class name.
*/
+ (instancetype)objectWithClassName:(NSString *)className;
/*!
@abstract Creates a reference to an existing PFObject for use in creating associations between PFObjects.
@discussion Calling <isDataAvailable> on this object will return `NO` until <fetchIfNeeded> has been called.
No network request will be made.
@param className The object's class.
@param objectId The object id for the referenced object.
@returns A `PFObject` instance without data.
*/
+ (instancetype)objectWithoutDataWithClassName:(NSString *)className
objectId:(PF_NULLABLE NSString *)objectId;
/*!
@abstract Creates a new `PFObject` with a class name, initialized with data
constructed from the specified set of objects and keys.
@param className The object's class.
@param dictionary An `NSDictionary` of keys and objects to set on the new `PFObject`.
@returns A PFObject with the given class name and set with the given data.
*/
+ (PFObject *)objectWithClassName:(NSString *)className
dictionary:(PF_NULLABLE NSDictionary *)dictionary;
/*!
@abstract Initializes a new empty `PFObject` instance with a class name.
@param newClassName A class name can be any alphanumeric string that begins with a letter.
It represents an object in your app, like a 'User' or a 'Document'.
@returns Returns the object that is instantiated with the given class name.
*/
- (instancetype)initWithClassName:(NSString *)newClassName;
///--------------------------------------
/// @name Managing Object Properties
///--------------------------------------
/*!
@abstract The class name of the object.
*/
@property (strong, readonly) NSString *parseClassName;
/*!
@abstract The id of the object.
*/
@property (PF_NULLABLE_PROPERTY nonatomic, strong) NSString *objectId;
/*!
@abstract When the object was last updated.
*/
@property (PF_NULLABLE_PROPERTY nonatomic, strong, readonly) NSDate *updatedAt;
/*!
@abstract When the object was created.
*/
@property (PF_NULLABLE_PROPERTY nonatomic, strong, readonly) NSDate *createdAt;
/*!
@abstract The ACL for this object.
*/
@property (PF_NULLABLE_PROPERTY nonatomic, strong) PFACL *ACL;
/*!
@abstract Returns an array of the keys contained in this object.
@discussion This does not include `createdAt`, `updatedAt`, `authData`, or `objectId`.
It does include things like username and ACL.
*/
- (NSArray *)allKeys;
///--------------------------------------
/// @name Accessors
///--------------------------------------
/*!
@abstract Returns the value associated with a given key.
@param key The key for which to return the corresponding value.
*/
- (PF_NULLABLE_S id)objectForKey:(NSString *)key;
/*!
@abstract Sets the object associated with a given key.
@param object The object for `key`. A strong reference to the object is maintaned by PFObject.
Raises an `NSInvalidArgumentException` if `object` is `nil`.
If you need to represent a `nil` value - use `NSNull`.
@param key The key for `object`.
Raises an `NSInvalidArgumentException` if `key` is `nil`.
@see setObject:forKeyedSubscript:
*/
- (void)setObject:(id)object forKey:(NSString *)key;
/*!
@abstract Unsets a key on the object.
@param key The key.
*/
- (void)removeObjectForKey:(NSString *)key;
/*!
@abstract Returns the value associated with a given key.
@discussion This method enables usage of literal syntax on `PFObject`.
E.g. `NSString *value = object[@"key"];`
@param key The key for which to return the corresponding value.
@see objectForKey:
*/
- (PF_NULLABLE_S id)objectForKeyedSubscript:(NSString *)key;
/*!
@abstract Returns the value associated with a given key.
@discussion This method enables usage of literal syntax on `PFObject`.
E.g. `object[@"key"] = @"value";`
@param object The object for `key`. A strong reference to the object is maintaned by PFObject.
Raises an `NSInvalidArgumentException` if `object` is `nil`.
If you need to represent a `nil` value - use `NSNull`.
@param key The key for `object`.
Raises an `NSInvalidArgumentException` if `key` is `nil`.
@see setObject:forKey:
*/
- (void)setObject:(PF_NULLABLE_S id)object forKeyedSubscript:(NSString *)key;
/*!
@abstract Returns the relation object associated with the given key.
@param key The key that the relation is associated with.
*/
- (PFRelation *)relationForKey:(NSString *)key;
/*!
@abstract Returns the relation object associated with the given key.
@param key The key that the relation is associated with.
@deprecated Please use `[PFObject relationForKey:]` instead.
*/
- (PFRelation *)relationforKey:(NSString *)key PARSE_DEPRECATED("Please use -relationForKey: instead.");
///--------------------------------------
/// @name Array Accessors
///--------------------------------------
/*!
@abstract Adds an object to the end of the array associated with a given key.
@param object The object to add.
@param key The key.
*/
- (void)addObject:(id)object forKey:(NSString *)key;
/*!
@abstract Adds the objects contained in another array to the end of the array associated with a given key.
@param objects The array of objects to add.
@param key The key.
*/
- (void)addObjectsFromArray:(NSArray *)objects forKey:(NSString *)key;
/*!
@abstract Adds an object to the array associated with a given key, only if it is not already present in the array.
@discussion The position of the insert is not guaranteed.
@param object The object to add.
@param key The key.
*/
- (void)addUniqueObject:(id)object forKey:(NSString *)key;
/*!
@abstract Adds the objects contained in another array to the array associated with a given key,
only adding elements which are not already present in the array.
@dicsussion The position of the insert is not guaranteed.
@param objects The array of objects to add.
@param key The key.
*/
- (void)addUniqueObjectsFromArray:(NSArray *)objects forKey:(NSString *)key;
/*!
@abstract Removes all occurrences of an object from the array associated with a given key.
@param object The object to remove.
@param key The key.
*/
- (void)removeObject:(id)object forKey:(NSString *)key;
/*!
@abstract Removes all occurrences of the objects contained in another array from the array associated with a given key.
@param objects The array of objects to remove.
@param key The key.
*/
- (void)removeObjectsInArray:(NSArray *)objects forKey:(NSString *)key;
///--------------------------------------
/// @name Increment
///--------------------------------------
/*!
@abstract Increments the given key by `1`.
@param key The key.
*/
- (void)incrementKey:(NSString *)key;
/*!
@abstract Increments the given key by a number.
@param key The key.
@param amount The amount to increment.
*/
- (void)incrementKey:(NSString *)key byAmount:(NSNumber *)amount;
///--------------------------------------
/// @name Saving Objects
///--------------------------------------
/*!
@abstract *Synchronously* saves the `PFObject`.
@returns Returns whether the save succeeded.
*/
- (BOOL)save;
/*!
@abstract *Synchronously* saves the `PFObject` and sets an error if it occurs.
@param error Pointer to an NSError that will be set if necessary.
@returns Returns whether the save succeeded.
*/
- (BOOL)save:(NSError **)error;
/*!
@abstract Saves the `PFObject` *asynchronously*.
@returns The task that encapsulates the work being done.
*/
- (BFTask *)saveInBackground;
/*!
@abstract Saves the `PFObject` *asynchronously* and executes the given callback block.
@param block The block to execute.
It should have the following argument signature: `^(BOOL succeeded, NSError *error)`.
*/
- (void)saveInBackgroundWithBlock:(PF_NULLABLE PFBooleanResultBlock)block;
/*
@abstract Saves the `PFObject` 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:(PF_NULLABLE_S id)target selector:(PF_NULLABLE_S SEL)selector;
/*!
@abstract Saves this object to the server at some unspecified time in the future,
even if Parse is currently inaccessible.
@discussion Use this when you may not have a solid network connection, and don't need to know when the save completes.
If there is some problem with the object such that it can't be saved, it will be silently discarded. If the save
completes successfully while the object is still in memory, then callback will be called.
Objects saved with this method will be stored locally in an on-disk cache until they can be delivered to Parse.
They will be sent immediately if possible. Otherwise, they will be sent the next time a network connection is
available. Objects saved this way will persist even after the app is closed, in which case they will be sent the
next time the app is opened. If more than 10MB of data is waiting to be sent, subsequent calls to <saveEventually>
will cause old saves to be silently discarded until the connection can be re-established, and the queued objects
can be saved.
@returns The task that encapsulates the work being done.
*/
- (BFTask *)saveEventually;
/*!
@abstract Saves this object to the server at some unspecified time in the future,
even if Parse is currently inaccessible.
@discussion Use this when you may not have a solid network connection, and don't need to know when the save completes.
If there is some problem with the object such that it can't be saved, it will be silently discarded. If the save
completes successfully while the object is still in memory, then callback will be called.
Objects saved with this method will be stored locally in an on-disk cache until they can be delivered to Parse.
They will be sent immediately if possible. Otherwise, they will be sent the next time a network connection is
available. Objects saved this way will persist even after the app is closed, in which case they will be sent the
next time the app is opened. If more than 10MB of data is waiting to be sent, subsequent calls to <saveEventually>
will cause old saves to be silently discarded until the connection can be re-established, and the queued objects
can be saved.
@param callback The block to execute.
It should have the following argument signature: `^(BOOL succeeded, NSError *error)`.
*/
- (void)saveEventually:(PF_NULLABLE PFBooleanResultBlock)callback;
///--------------------------------------
/// @name Saving Many Objects
///--------------------------------------
/*!
@abstract Saves a collection of objects *synchronously all at once.
@param objects The array of objects to save.
@returns Returns whether the save succeeded.
*/
+ (BOOL)saveAll:(PF_NULLABLE NSArray *)objects;
/*!
@abstract Saves a collection of objects *synchronously* all at once and sets an error if necessary.
@param objects The array of objects to save.
@param error Pointer to an `NSError` that will be set if necessary.
@returns Returns whether the save succeeded.
*/
+ (BOOL)saveAll:(PF_NULLABLE NSArray *)objects error:(NSError **)error;
/*!
@abstract Saves a collection of objects all at once *asynchronously*.
@param objects The array of objects to save.
@returns The task that encapsulates the work being done.
*/
+ (BFTask *)saveAllInBackground:(PF_NULLABLE NSArray *)objects;
/*!
@abstract Saves a collection of objects all at once `asynchronously` and executes the block when done.
@param objects The array of objects to save.
@param block The block to execute.
It should have the following argument signature: `^(BOOL succeeded, NSError *error)`.
*/
+ (void)saveAllInBackground:(PF_NULLABLE NSArray *)objects
block:(PF_NULLABLE PFBooleanResultBlock)block;
/*
@abstract Saves a collection of objects all at once *asynchronously* and calls a callback when done.
@param objects The array of objects to save.
@param target The object to call selector on.
@param selector The selector to call.
It should have the following signature: `(void)callbackWithResult:(NSNumber *)number 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)saveAllInBackground:(PF_NULLABLE NSArray *)objects
target:(PF_NULLABLE_S id)target
selector:(PF_NULLABLE_S SEL)selector;
///--------------------------------------
/// @name Deleting Many Objects
///--------------------------------------
/*!
@abstract *Synchronously* deletes a collection of objects all at once.
@param objects The array of objects to delete.
@returns Returns whether the delete succeeded.
*/
+ (BOOL)deleteAll:(PF_NULLABLE NSArray *)objects;
/*!
@abstract *Synchronously* deletes a collection of objects all at once and sets an error if necessary.
@param objects The array of objects to delete.
@param error Pointer to an `NSError` that will be set if necessary.
@returns Returns whether the delete succeeded.
*/
+ (BOOL)deleteAll:(PF_NULLABLE NSArray *)objects error:(NSError **)error;
/*!
@abstract Deletes a collection of objects all at once asynchronously.
@param objects The array of objects to delete.
@returns The task that encapsulates the work being done.
*/
+ (BFTask *)deleteAllInBackground:(PF_NULLABLE NSArray *)objects;
/*!
@abstract Deletes a collection of objects all at once *asynchronously* and executes the block when done.
@param objects The array of objects to delete.
@param block The block to execute.
It should have the following argument signature: `^(BOOL succeeded, NSError *error)`.
*/
+ (void)deleteAllInBackground:(PF_NULLABLE NSArray *)objects
block:(PF_NULLABLE PFBooleanResultBlock)block;
/*
@abstract Deletes a collection of objects all at once *asynchronously* and calls a callback when done.
@param objects The array of objects to delete.
@param target The object to call selector on.
@param selector The selector to call.
It should have the following signature: `(void)callbackWithResult:(NSNumber *)number 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)deleteAllInBackground:(PF_NULLABLE NSArray *)objects
target:(PF_NULLABLE_S id)target
selector:(PF_NULLABLE_S SEL)selector;
///--------------------------------------
/// @name Getting an Object
///--------------------------------------
/*!
@abstract Gets whether the `PFObject` has been fetched.
@returns `YES` if the PFObject is new or has been fetched or refreshed, otherwise `NO`.
*/
- (BOOL)isDataAvailable;
#if PARSE_IOS_ONLY
/*!
@abstract Refreshes the PFObject with the current data from the server.
@deprecated Please use `-fetch` instead.
*/
- (void)refresh PARSE_DEPRECATED("Please use `-fetch` instead.");
/*!
@abstract *Synchronously* refreshes the `PFObject` with the current data from the server and sets an error if it occurs.
@param error Pointer to an `NSError` that will be set if necessary.
@deprecated Please use `-fetch:` instead.
*/
- (void)refresh:(NSError **)error PARSE_DEPRECATED("Please use `-fetch:` instead.");
/*!
@abstract *Asynchronously* refreshes the `PFObject` and executes the given callback block.
@param block The block to execute.
The block should have the following argument signature: `^(PFObject *object, NSError *error)`
@deprecated Please use `-fetchInBackgroundWithBlock:` instead.
*/
- (void)refreshInBackgroundWithBlock:(PF_NULLABLE PFObjectResultBlock)block PARSE_DEPRECATED("Please use `-fetchInBackgroundWithBlock:` instead.");
/*
@abstract *Asynchronously* refreshes the `PFObject` and calls the given callback.
@param target The target on which the selector will be called.
@param selector The selector to call.
It should have the following signature: `(void)callbackWithResult:(PFObject *)refreshedObject error:(NSError *)error`.
`error` will be `nil` on success and set if there was an error.
`refreshedObject` will be the `PFObject` with the refreshed data.
@deprecated Please use `fetchInBackgroundWithTarget:selector:` instead.
*/
- (void)refreshInBackgroundWithTarget:(PF_NULLABLE_S id)target
selector:(PF_NULLABLE_S SEL)selector PARSE_DEPRECATED("Please use `fetchInBackgroundWithTarget:selector:` instead.");
#endif
/*!
@abstract *Synchronously* fetches the PFObject with the current data from the server.
*/
- (void)fetch;
/*!
@abstract *Synchronously* fetches the PFObject with the current data from the server and sets an error if it occurs.
@param error Pointer to an `NSError` that will be set if necessary.
*/
- (void)fetch:(NSError **)error;
/*!
@abstract *Synchronously* fetches the `PFObject` data from the server if <isDataAvailable> is `NO`.
*/
- (PF_NULLABLE PFObject *)fetchIfNeeded;
/*!
@abstract *Synchronously* fetches the `PFObject` data from the server if <isDataAvailable> is `NO`.
@param error Pointer to an `NSError` that will be set if necessary.
*/
- (PF_NULLABLE PFObject *)fetchIfNeeded:(NSError **)error;
/*!
@abstract Fetches the `PFObject` *asynchronously* and sets it as a result for the task.
@returns The task that encapsulates the work being done.
*/
- (BFTask *)fetchInBackground;
/*!
@abstract Fetches the PFObject *asynchronously* and executes the given callback block.
@param block The block to execute.
It should have the following argument signature: `^(PFObject *object, NSError *error)`.
*/
- (void)fetchInBackgroundWithBlock:(PF_NULLABLE PFObjectResultBlock)block;
/*
@abstract Fetches the `PFObject *asynchronously* and calls the given callback.
@param target The target on which the selector will be called.
@param selector The selector to call.
It should have the following signature: `(void)callbackWithResult:(PFObject *)refreshedObject error:(NSError *)error`.
`error` will be `nil` on success and set if there was an error.
`refreshedObject` will be the `PFObject` with the refreshed data.
*/
- (void)fetchInBackgroundWithTarget:(PF_NULLABLE_S id)target selector:(PF_NULLABLE_S SEL)selector;
/*!
@abstract Fetches the `PFObject` data *asynchronously* if isDataAvailable is `NO`,
then sets it as a result for the task.
@returns The task that encapsulates the work being done.
*/
- (BFTask *)fetchIfNeededInBackground;
/*!
@abstract Fetches the `PFObject` data *asynchronously* if <isDataAvailable> is `NO`, then calls the callback block.
@param block The block to execute.
It should have the following argument signature: `^(PFObject *object, NSError *error)`.
*/
- (void)fetchIfNeededInBackgroundWithBlock:(PF_NULLABLE PFObjectResultBlock)block;
/*
@abstract Fetches the PFObject's data asynchronously if isDataAvailable is false, then calls the callback.
@param target The target on which the selector will be called.
@param selector The selector to call.
It should have the following signature: `(void)callbackWithResult:(PFObject *)fetchedObject error:(NSError *)error`.
`error` will be `nil` on success and set if there was an error.
`refreshedObject` will be the `PFObject` with the refreshed data.
*/
- (void)fetchIfNeededInBackgroundWithTarget:(PF_NULLABLE_S id)target
selector:(PF_NULLABLE_S SEL)selector;
///--------------------------------------
/// @name Getting Many Objects
///--------------------------------------
/*!
@abstract *Synchronously* fetches all of the `PFObject` objects with the current data from the server.
@param objects The list of objects to fetch.
*/
+ (void)fetchAll:(PF_NULLABLE NSArray *)objects;
/*!
@abstract *Synchronously* fetches all of the `PFObject` objects with the current data from the server
and sets an error if it occurs.
@param objects The list of objects to fetch.
@param error Pointer to an `NSError` that will be set if necessary.
*/
+ (void)fetchAll:(PF_NULLABLE NSArray *)objects error:(NSError **)error;
/*!
@abstract *Synchronously* fetches all of the `PFObject` objects with the current data from the server.
@param objects The list of objects to fetch.
*/
+ (void)fetchAllIfNeeded:(PF_NULLABLE NSArray *)objects;
/*!
@abstract *Synchronously* fetches all of the `PFObject` objects with the current data from the server
and sets an error if it occurs.
@param objects The list of objects to fetch.
@param error Pointer to an `NSError` that will be set if necessary.
*/
+ (void)fetchAllIfNeeded:(PF_NULLABLE NSArray *)objects error:(NSError **)error;
/*!
@abstract Fetches all of the `PFObject` objects with the current data from the server *asynchronously*.
@param objects The list of objects to fetch.
@returns The task that encapsulates the work being done.
*/
+ (BFTask *)fetchAllInBackground:(PF_NULLABLE NSArray *)objects;
/*!
@abstract Fetches all of the `PFObject` objects with the current data from the server *asynchronously*
and calls the given block.
@param objects The list of objects to fetch.
@param block The block to execute.
It should have the following argument signature: `^(NSArray *objects, NSError *error)`.
*/
+ (void)fetchAllInBackground:(PF_NULLABLE NSArray *)objects
block:(PF_NULLABLE PFArrayResultBlock)block;
/*
@abstract Fetches all of the `PFObject` objects with the current data from the server *asynchronously*
and calls the given callback.
@param objects The list of objects to fetch.
@param target The target on which the selector will be called.
@param selector The selector to call.
It should have the following signature: `(void)callbackWithResult:(NSArray *)fetchedObjects error:(NSError *)error`.
`error` will be `nil` on success and set if there was an error.
`fetchedObjects` will the array of `PFObject` objects that were fetched.
*/
+ (void)fetchAllInBackground:(PF_NULLABLE NSArray *)objects
target:(PF_NULLABLE_S id)target
selector:(PF_NULLABLE_S SEL)selector;
/*!
@abstract Fetches all of the `PFObject` objects with the current data from the server *asynchronously*.
@param objects The list of objects to fetch.
@returns The task that encapsulates the work being done.
*/
+ (BFTask *)fetchAllIfNeededInBackground:(PF_NULLABLE NSArray *)objects;
/*!
@abstract Fetches all of the PFObjects with the current data from the server *asynchronously*
and calls the given block.
@param objects The list of objects to fetch.
@param block The block to execute.
It should have the following argument signature: `^(NSArray *objects, NSError *error)`.
*/
+ (void)fetchAllIfNeededInBackground:(PF_NULLABLE NSArray *)objects
block:(PF_NULLABLE PFArrayResultBlock)block;
/*
@abstract Fetches all of the PFObjects with the current data from the server *asynchronously*
and calls the given callback.
@param objects The list of objects to fetch.
@param target The target on which the selector will be called.
@param selector The selector to call.
It should have the following signature: `(void)callbackWithResult:(NSArray *)fetchedObjects error:(NSError *)error`.
`error` will be `nil` on success and set if there was an error.
`fetchedObjects` will the array of `PFObject` objects that were fetched.
*/
+ (void)fetchAllIfNeededInBackground:(PF_NULLABLE NSArray *)objects
target:(PF_NULLABLE_S id)target
selector:(PF_NULLABLE_S SEL)selector;
///--------------------------------------
/// @name Fetching From Local Datastore
///--------------------------------------
/*!
@abstract *Synchronously* loads data from the local datastore into this object,
if it has not been fetched from the server already.
*/
- (void)fetchFromLocalDatastore;
/*!
@abstract *Synchronously* loads data from the local datastore into this object, if it has not been fetched
from the server already.
@discussion If the object is not stored in the local datastore, this `error` will be set to
return kPFErrorCacheMiss.
@param error Pointer to an `NSError` that will be set if necessary.
*/
- (void)fetchFromLocalDatastore:(NSError **)error;
/*!
@abstract *Asynchronously* loads data from the local datastore into this object,
if it has not been fetched from the server already.
@returns The task that encapsulates the work being done.
*/
- (BFTask *)fetchFromLocalDatastoreInBackground;
/*!
@abstract *Asynchronously* loads data from the local datastore into this object,
if it has not been fetched from the server already.
@param block The block to execute.
It should have the following argument signature: `^(PFObject *object, NSError *error)`.
*/
- (void)fetchFromLocalDatastoreInBackgroundWithBlock:(PF_NULLABLE PFObjectResultBlock)block;
///--------------------------------------
/// @name Deleting an Object
///--------------------------------------
/*!
@abstract *Synchronously* deletes the `PFObject`.
@returns Returns whether the delete succeeded.
*/
- (BOOL)delete;
/*!
@abstract *Synchronously* deletes the `PFObject` and sets an error if it occurs.
@param error Pointer to an `NSError` that will be set if necessary.
@returns Returns whether the delete succeeded.
*/
- (BOOL)delete:(NSError **)error;
/*!
@abstract Deletes the `PFObject` *asynchronously*.
@returns The task that encapsulates the work being done.
*/
- (BFTask *)deleteInBackground;
/*!
@abstract Deletes the `PFObject` *asynchronously* and executes the given callback block.
@param block The block to execute.
It should have the following argument signature: `^(BOOL succeeded, NSError *error)`.
*/
- (void)deleteInBackgroundWithBlock:(PF_NULLABLE PFBooleanResultBlock)block;
/*
@abstract Deletes the `PFObject` *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)deleteInBackgroundWithTarget:(PF_NULLABLE_S id)target
selector:(PF_NULLABLE_S SEL)selector;
/*!
@abstract Deletes this object from the server at some unspecified time in the future,
even if Parse is currently inaccessible.
@discussion Use this when you may not have a solid network connection,
and don't need to know when the delete completes. If there is some problem with the object
such that it can't be deleted, the request will be silently discarded.
Delete instructions made with this method will be stored locally in an on-disk cache until they can be transmitted
to Parse. They will be sent immediately if possible. Otherwise, they will be sent the next time a network connection
is available. Delete requests will persist even after the app is closed, in which case they will be sent the
next time the app is opened. If more than 10MB of <saveEventually> or <deleteEventually> commands are waiting
to be sent, subsequent calls to <saveEventually> or <deleteEventually> will cause old requests to be silently discarded
until the connection can be re-established, and the queued requests can go through.
@returns The task that encapsulates the work being done.
*/
- (BFTask *)deleteEventually;
///--------------------------------------
/// @name Dirtiness
///--------------------------------------
/*!
@abstract Gets whether any key-value pair in this object (or its children)
has been added/updated/removed and not saved yet.
@returns Returns whether this object has been altered and not saved yet.
*/
- (BOOL)isDirty;
/*!
@abstract Get whether a value associated with a key has been added/updated/removed and not saved yet.
@param key The key to check for
@returns Returns whether this key has been altered and not saved yet.
*/
- (BOOL)isDirtyForKey:(NSString *)key;
///--------------------------------------
/// @name Pinning
///--------------------------------------
/*!
@abstract *Synchronously* stores the object and every object it points to in the local datastore, recursively,
using a default pin name: `PFObjectDefaultPin`.
@discussion If those other objects have not been fetched from Parse, they will not be stored. However,
if they have changed data, all the changes will be retained. To get the objects back later, you can
use a <PFQuery> that uses <[PFQuery fromLocalDatastore]>, or you can create an unfetched pointer with
<[PFObject objectWithoutDataWithClassName:objectId:]> and then call <fetchFromLocalDatastore> on it.
@returns Returns whether the pin succeeded.
@see unpin:
@see PFObjectDefaultPin
*/
- (BOOL)pin;
/*!
@abstract *Synchronously* stores the object and every object it points to in the local datastore, recursively,
using a default pin name: `PFObjectDefaultPin`.
@discussion If those other objects have not been fetched from Parse, they will not be stored. However,
if they have changed data, all the changes will be retained. To get the objects back later, you can
use a <PFQuery> that uses <[PFQuery fromLocalDatastore]>, or you can create an unfetched pointer with
<[PFObject objectWithoutDataWithClassName:objectId:]> and then call <fetchFromLocalDatastore> on it.
@param error Pointer to an `NSError` that will be set if necessary.
@returns Returns whether the pin succeeded.
@see unpin:
@see PFObjectDefaultPin
*/
- (BOOL)pin:(NSError **)error;
/*!
@abstract *Synchronously* stores the object and every object it points to in the local datastore, recursively.
@discussion If those other objects have not been fetched from Parse, they will not be stored. However,
if they have changed data, all the changes will be retained. To get the objects back later, you can
use a <PFQuery> that uses <[PFQuery fromLocalDatastore]>, or you can create an unfetched pointer with
<[PFObject objectWithoutDataWithClassName:objectId:]> and then call <fetchFromLocalDatastore> on it.
@param name The name of the pin.
@returns Returns whether the pin succeeded.
@see unpinWithName:
*/
- (BOOL)pinWithName:(NSString *)name;
/*!
@abstract *Synchronously* stores the object and every object it points to in the local datastore, recursively.
@discussion If those other objects have not been fetched from Parse, they will not be stored. However,
if they have changed data, all the changes will be retained. To get the objects back later, you can
use a <PFQuery> that uses <[PFQuery fromLocalDatastore]>, or you can create an unfetched pointer with
<[PFObject objectWithoutDataWithClassName:objectId:]> and then call <fetchFromLocalDatastore> on it.
@param name The name of the pin.
@param error Pointer to an `NSError` that will be set if necessary.
@returns Returns whether the pin succeeded.
@see unpinWithName:
*/
- (BOOL)pinWithName:(NSString *)name
error:(NSError **)error;
/*!
@abstract *Asynchronously* stores the object and every object it points to in the local datastore, recursively,
using a default pin name: `PFObjectDefaultPin`.
@discussion If those other objects have not been fetched from Parse, they will not be stored. However,
if they have changed data, all the changes will be retained. To get the objects back later, you can
use a <PFQuery> that uses <[PFQuery fromLocalDatastore]>, or you can create an unfetched pointer with
<[PFObject objectWithoutDataWithClassName:objectId:]> and then call <fetchFromLocalDatastore> on it.
@returns The task that encapsulates the work being done.
@see unpinInBackground
@see PFObjectDefaultPin
*/
- (BFTask *)pinInBackground;
/*!
@abstract *Asynchronously* stores the object and every object it points to in the local datastore, recursively,
using a default pin name: `PFObjectDefaultPin`.
@discussion If those other objects have not been fetched from Parse, they will not be stored. However,
if they have changed data, all the changes will be retained. To get the objects back later, you can
use a <PFQuery> that uses <[PFQuery fromLocalDatastore]>, or you can create an unfetched pointer with
<[PFObject objectWithoutDataWithClassName:objectId:]> and then call <fetchFromLocalDatastore> on it.
@param block The block to execute.
It should have the following argument signature: `^(BOOL succeeded, NSError *error)`.
@see unpinInBackgroundWithBlock:
@see PFObjectDefaultPin
*/
- (void)pinInBackgroundWithBlock:(PF_NULLABLE PFBooleanResultBlock)block;
/*!
@abstract *Asynchronously* stores the object and every object it points to in the local datastore, recursively.
@discussion If those other objects have not been fetched from Parse, they will not be stored. However,
if they have changed data, all the changes will be retained. To get the objects back later, you can
use a <PFQuery> that uses <[PFQuery fromLocalDatastore]>, or you can create an unfetched pointer with
<[PFObject objectWithoutDataWithClassName:objectId:]> and then call <fetchFromLocalDatastore> on it.
@param name The name of the pin.
@returns The task that encapsulates the work being done.
@see unpinInBackgroundWithName:
*/
- (BFTask *)pinInBackgroundWithName:(NSString *)name;
/*!
@abstract *Asynchronously* stores the object and every object it points to in the local datastore, recursively.
@discussion If those other objects have not been fetched from Parse, they will not be stored. However,
if they have changed data, all the changes will be retained. To get the objects back later, you can
use a <PFQuery> that uses <[PFQuery fromLocalDatastore]>, or you can create an unfetched pointer with
<[PFObject objectWithoutDataWithClassName:objectId:]> and then call <fetchFromLocalDatastore> on it.
@param name The name of the pin.
@param block The block to execute.
It should have the following argument signature: `^(BOOL succeeded, NSError *error)`.
@see unpinInBackgroundWithName:block:
*/
- (void)pinInBackgroundWithName:(NSString *)name block:(PF_NULLABLE PFBooleanResultBlock)block;
///--------------------------------------
/// @name Pinning Many Objects
///--------------------------------------
/*!
@abstract *Synchronously* stores the objects and every object they point to in the local datastore, recursively,
using a default pin name: `PFObjectDefaultPin`.
@discussion If those other objects have not been fetched from Parse, they will not be stored. However,
if they have changed data, all the changes will be retained. To get the objects back later, you can
use a <PFQuery> that uses <[PFQuery fromLocalDatastore]>, or you can create an unfetched pointer with
`[PFObject objectWithoutDataWithClassName:objectId:]` and then call `fetchFromLocalDatastore:` on it.
@param objects The objects to be pinned.
@returns Returns whether the pin succeeded.
@see unpinAll: