/
coredata.cs
3090 lines (2402 loc) · 106 KB
/
coredata.cs
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
// This file describes the API that the generator will produce
//
// Authors:
// MonoMac community
// Miguel de Icaza
//
// Copyright 2009, 2011, MonoMac community
// Copyright 2011, 2015 Xamarin Inc.
//
using System;
using Foundation;
using ObjCRuntime;
using CloudKit;
#if MONOMAC
using AppKit;
#endif
#if !WATCH
using CoreSpotlight;
#endif
#if !NET
using NativeHandle = System.IntPtr;
#endif
namespace CoreData {
[StrongDictionary ("UserInfoKeys")]
interface UserInfo {
NSError [] DetailedErrors { get; set; }
NSManagedObject ObjectForValidationError { get; set; }
NSString KeyForValidationError { get; set; }
NSPredicate PredicateForValidationError { get; set; }
NSValue ValueForValidationError { get; set; }
NSMergeConflict [] PersistentStoreSaveConflicts { get; set; }
NSPersistentStore [] AffectedStoresForError { get; set; }
}
[Static]
interface UserInfoKeys {
[Field ("NSDetailedErrorsKey")]
NSString DetailedErrorsKey { get; }
[Field ("NSValidationObjectErrorKey")]
NSString ObjectForValidationErrorKey { get; }
[Field ("NSValidationKeyErrorKey")]
NSString KeyForValidationErrorKey { get; }
[Field ("NSValidationPredicateErrorKey")]
NSString PredicateForValidationErrorKey { get; }
[Field ("NSValidationValueErrorKey")]
NSString ValueForValidationErrorKey { get; }
[Field ("NSPersistentStoreSaveConflictsErrorKey")]
NSString PersistentStoreSaveConflictsKey { get; }
[Field ("NSAffectedStoresErrorKey")]
NSString AffectedStoresForErrorKey { get; }
[Watch (10, 0), TV (17, 0), Mac (14, 0), iOS (17, 0), MacCatalyst (17, 0)]
[Field ("NSPersistentStoreStagedMigrationManagerOptionKey")]
NSString StagedMigrationManagerOptionKey { get; }
[Watch (7, 0), TV (14, 0), Mac (11, 0), iOS (14, 0), MacCatalyst (17, 0)]
[Field ("NSPersistentStoreDeferredLightweightMigrationOptionKey")]
NSString DeferredLightweightMigrationOptionKey { get; }
}
[NoWatch]
[NoTV]
[Native] // NUInteger -> NSPersistentStoreCoordinator.h
[Deprecated (PlatformName.iOS, 10, 0, message: "Please see the release notes and Core Data documentation.")]
[Deprecated (PlatformName.MacOSX, 10, 12, message: "Please see the release notes and Core Data documentation.")]
[MacCatalyst (13, 1)]
[Deprecated (PlatformName.MacCatalyst, 13, 1, message: "Please see the release notes and Core Data documentation.")]
public enum NSPersistentStoreUbiquitousTransitionType : ulong {
AccountAdded = 1,
AccountRemoved,
ContentRemoved,
InitialImportCompleted
}
[Native]
public enum NSSnapshotEventType : ulong {
UndoInsertion = 1 << 1,
UndoDeletion = 1 << 2,
UndoUpdate = 1 << 3,
Rollback = 1 << 4,
Refresh = 1 << 5,
MergePolicy = 1 << 6
}
[BaseType (typeof (NSPersistentStore))]
// Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: NSMappedObjectStore must be initialized with initWithPersistentStoreCoordinator:configurationName:URL:options
[DisableDefaultCtor]
interface NSAtomicStore {
[Export ("initWithPersistentStoreCoordinator:configurationName:URL:options:")]
NativeHandle Constructor ([NullAllowed] NSPersistentStoreCoordinator coordinator, [NullAllowed] string configurationName, NSUrl url, [NullAllowed] NSDictionary options);
[Export ("load:")]
bool Load (out NSError error);
[Export ("save:")]
bool Save (out NSError error);
[Export ("newCacheNodeForManagedObject:")]
NSAtomicStoreCacheNode NewCacheNodeForManagedObject (NSManagedObject managedObject);
[Export ("updateCacheNode:fromManagedObject:")]
void UpdateCacheNode (NSAtomicStoreCacheNode node, NSManagedObject managedObject);
[Export ("cacheNodes")]
#if XAMCORE_5_0
NSSet<NSAtomicStoreCacheNode> CacheNodes { get; }
#else
NSSet CacheNodes { get; }
#endif
[Export ("addCacheNodes:")]
#if XAMCORE_5_0
void AddCacheNodes (NSSet<NSAtomicStoreCacheNode> cacheNodes);
#else
void AddCacheNodes (NSSet cacheNodes);
#endif
[Export ("willRemoveCacheNodes:")]
#if XAMCORE_5_0
void WillRemoveCacheNodes (NSSet<NSAtomicStoreCacheNode> cacheNodes);
#else
void WillRemoveCacheNodes (NSSet cacheNodes);
#endif
[Export ("cacheNodeForObjectID:")]
[return: NullAllowed]
NSAtomicStoreCacheNode CacheNodeForObjectID (NSManagedObjectID objectID);
[Export ("objectIDForEntity:referenceObject:")]
NSManagedObjectID ObjectIDForEntity (NSEntityDescription entity, NSObject data);
[Export ("newReferenceObjectForManagedObject:")]
NSAtomicStore NewReferenceObjectForManagedObject (NSManagedObject managedObject);
[Export ("referenceObjectForObjectID:")]
NSAtomicStore ReferenceObjectForObjectID (NSManagedObjectID objectID);
}
[MacCatalyst (13, 1)]
[BaseType (typeof (NSObject))]
interface NSFetchIndexElementDescription : NSCoding, NSCopying {
[Export ("initWithProperty:collationType:")]
NativeHandle Constructor (NSPropertyDescription property, NSFetchIndexElementType collationType);
[NullAllowed, Export ("property", ArgumentSemantic.Retain)]
NSPropertyDescription Property { get; }
[NullAllowed, Export ("propertyName", ArgumentSemantic.Retain)]
string PropertyName { get; }
[Export ("collationType", ArgumentSemantic.Assign)]
NSFetchIndexElementType CollationType { get; set; }
[Export ("ascending")]
bool IsAscending { [Bind ("isAscending")] get; set; }
[NullAllowed, Export ("indexDescription", ArgumentSemantic.Assign)]
NSFetchIndexDescription IndexDescription { get; }
}
[MacCatalyst (13, 1)]
[BaseType (typeof (NSObject))]
interface NSFetchIndexDescription : NSCoding, NSCopying {
[Export ("initWithName:elements:")]
NativeHandle Constructor (string name, [NullAllowed] NSFetchIndexElementDescription [] elements);
[Export ("name")]
string Name { get; set; }
[Export ("elements", ArgumentSemantic.Copy)]
NSFetchIndexElementDescription [] Elements { get; set; }
[NullAllowed, Export ("entity", ArgumentSemantic.Assign)]
NSEntityDescription Entity { get; }
[NullAllowed, Export ("partialIndexPredicate", ArgumentSemantic.Copy)]
NSPredicate PartialIndexPredicate { get; set; }
}
[BaseType (typeof (NSObject))]
// Objective-C exception thrown. Name: NSInvalidArgumentException Reason: NSAtomicStoreCacheNodes must be initialized using initWithObjectID:(NSManagedObjectID *)
[DisableDefaultCtor]
interface NSAtomicStoreCacheNode {
[Export ("initWithObjectID:")]
NativeHandle Constructor (NSManagedObjectID moid);
[Export ("objectID", ArgumentSemantic.Strong)]
NSManagedObjectID ObjectID { get; }
[NullAllowed, Export ("propertyCache", ArgumentSemantic.Retain)]
#if XAMCORE_5_0
NSMutableDictionary<NSString, NSObject> PropertyCache { get; set; }
#else
NSDictionary PropertyCache { get; set; }
#endif
[Export ("valueForKey:")]
[return: NullAllowed]
NSAtomicStoreCacheNode ValueForKey (string key);
[Export ("setValue:forKey:")]
void SetValue ([NullAllowed] NSObject value, string key);
}
[BaseType (typeof (NSPropertyDescription))]
interface NSAttributeDescription {
[Export ("attributeType")]
NSAttributeType AttributeType { get; set; }
// Default property value is null but it cannot be set to that value
// NSInternalInconsistencyException Reason: Can't set attributeValueClassName to nil for a non-transient attribute.
[Export ("attributeValueClassName")]
[NullAllowed]
string AttributeValueClassName { get; set; }
[NullAllowed] // by default this property is null
[Export ("defaultValue", ArgumentSemantic.Retain)]
NSObject DefaultValue { get; set; }
[Export ("versionHash")]
NSData VersionHash { get; }
[NullAllowed] // by default this property is null
[Export ("valueTransformerName")]
string ValueTransformerName { get; set; }
[Export ("allowsExternalBinaryDataStorage")]
bool AllowsExternalBinaryDataStorage { get; set; }
[Watch (6, 0), TV (13, 0), iOS (13, 0)]
[MacCatalyst (13, 1)]
[Export ("preservesValueInHistoryOnDeletion")]
bool PreservesValueInHistoryOnDeletion { get; set; }
[Watch (8, 0), TV (15, 0), Mac (12, 0), iOS (15, 0), MacCatalyst (15, 0)]
[Export ("allowsCloudEncryption")]
bool AllowsCloudEncryption { get; set; }
}
[BaseType (typeof (NSObject))]
interface NSEntityDescription : NSCoding, NSCopying {
[Static, Export ("entityForName:inManagedObjectContext:")]
[return: NullAllowed]
NSEntityDescription EntityForName (string entityName, NSManagedObjectContext context);
[Static, Export ("insertNewObjectForEntityForName:inManagedObjectContext:")]
#if !NET
NSObject InsertNewObjectForEntityForName (string entityName, NSManagedObjectContext context);
#else
NSManagedObject InsertNewObject (string entityName, NSManagedObjectContext context);
#endif
[Export ("managedObjectModel")]
NSManagedObjectModel ManagedObjectModel { get; }
[Export ("managedObjectClassName")]
[NullAllowed]
string ManagedObjectClassName { get; set; }
[NullAllowed, Export ("renamingIdentifier")]
string RenamingIdentifier { get; set; }
[NullAllowed] // by default this property is null
[Export ("name")]
string Name { get; set; }
[Export ("abstract")]
bool Abstract { [Bind ("isAbstract")] get; set; }
[Export ("subentitiesByName")]
#if XAMCORE_5_0
NSDictionary<NSString, NSEntityDescription> SubentitiesByName { get; }
#else
NSDictionary SubentitiesByName { get; }
#endif
[Export ("subentities", ArgumentSemantic.Retain)]
NSEntityDescription [] Subentities { get; set; }
[NullAllowed, Export ("superentity")]
NSEntityDescription Superentity { get; }
[Export ("propertiesByName")]
#if XAMCORE_5_0
NSDictionary<NSString, NSPropertyDescription> PropertiesByName { get; }
#else
NSDictionary PropertiesByName { get; }
#endif
[Export ("properties", ArgumentSemantic.Retain)]
NSPropertyDescription [] Properties { get; set; }
[NullAllowed, Export ("userInfo", ArgumentSemantic.Retain)]
NSDictionary UserInfo { get; set; }
[Export ("attributesByName")]
#if XAMCORE_5_0
NSDictionary<NSString, NSAttributeDescription> AttributesByName { get; }
#else
NSDictionary AttributesByName { get; }
#endif
[Export ("relationshipsByName")]
#if XAMCORE_5_0
NSDictionary<NSString, NSRelationshipDescription> RelationshipsByName { get; }
#else
NSDictionary RelationshipsByName { get; }
#endif
[Export ("relationshipsWithDestinationEntity:")]
NSRelationshipDescription [] RelationshipsWithDestinationEntity (NSEntityDescription entity);
[Export ("isKindOfEntity:")]
bool IsKindOfEntity (NSEntityDescription entity);
[Export ("versionHash")]
NSData VersionHash { get; }
[NullAllowed] // by default this property is null
[Export ("versionHashModifier")]
string VersionHashModifier { get; set; }
[Export ("compoundIndexes", ArgumentSemantic.Retain)]
[Deprecated (PlatformName.iOS, 11, 0, message: "Use 'NSEntityDescription.Indexes' instead.")]
[Deprecated (PlatformName.MacOSX, 10, 13, message: "Use 'NSEntityDescription.Indexes' instead.")]
[Deprecated (PlatformName.TvOS, 11, 0, message: "Use 'NSEntityDescription.Indexes' instead.")]
[Deprecated (PlatformName.WatchOS, 4, 0, message: "Use 'NSEntityDescription.Indexes' instead.")]
[Deprecated (PlatformName.MacCatalyst, 13, 1, message: "Use 'NSEntityDescription.Indexes' instead.")]
NSPropertyDescription [] CompoundIndexes { get; set; }
[MacCatalyst (13, 1)]
[Export ("indexes", ArgumentSemantic.Copy)]
NSFetchIndexDescription [] Indexes { get; set; }
// @property (strong) NSArray<NSArray<id __nonnull> * __nonnull> * __nonnull uniquenessConstraints __attribute__((availability(ios, introduced=9.0)));
[MacCatalyst (13, 1)]
[Internal, Export ("uniquenessConstraints", ArgumentSemantic.Strong)]
NSArray _UniquenessConstraints { get; set; }
[MacCatalyst (13, 1)]
[Export ("coreSpotlightDisplayNameExpression", ArgumentSemantic.Retain)]
NSExpression CoreSpotlightDisplayNameExpression { get; set; }
}
[BaseType (typeof (NSObject))]
interface NSEntityMapping {
[Export ("name")]
[NullAllowed]
string Name { get; set; }
[Export ("mappingType")]
NSEntityMappingType MappingType { get; set; }
[NullAllowed] // by default this property is null
[Export ("sourceEntityName")]
string SourceEntityName { get; set; }
[NullAllowed] // by default this property is null
[Export ("sourceEntityVersionHash", ArgumentSemantic.Copy)]
NSData SourceEntityVersionHash { get; set; }
[NullAllowed] // by default this property is null
[Export ("destinationEntityName", ArgumentSemantic.Copy)]
string DestinationEntityName { get; set; }
[NullAllowed] // by default this property is null
[Export ("destinationEntityVersionHash", ArgumentSemantic.Copy)]
NSData DestinationEntityVersionHash { get; set; }
[Export ("attributeMappings", ArgumentSemantic.Retain)]
[NullAllowed]
NSPropertyMapping [] AttributeMappings { get; set; }
[Export ("relationshipMappings", ArgumentSemantic.Retain)]
[NullAllowed]
NSPropertyMapping [] RelationshipMappings { get; set; }
[NullAllowed] // by default this property is null
[Export ("sourceExpression", ArgumentSemantic.Retain)]
NSExpression SourceExpression { get; set; }
[NullAllowed] // by default this property is null
[Export ("userInfo", ArgumentSemantic.Retain)]
NSDictionary UserInfo { get; set; }
[NullAllowed] // by default this property is null
[Export ("entityMigrationPolicyClassName")]
string EntityMigrationPolicyClassName { get; set; }
}
[BaseType (typeof (NSObject))]
interface NSEntityMigrationPolicy {
[Export ("beginEntityMapping:manager:error:")]
bool BeginEntityMapping (NSEntityMapping mapping, NSMigrationManager manager, out NSError error);
[Export ("createDestinationInstancesForSourceInstance:entityMapping:manager:error:")]
bool CreateDestinationInstancesForSourceInstance (NSManagedObject sInstance, NSEntityMapping mapping, NSMigrationManager manager, out NSError error);
[Export ("endInstanceCreationForEntityMapping:manager:error:")]
bool EndInstanceCreationForEntityMapping (NSEntityMapping mapping, NSMigrationManager manager, out NSError error);
[Export ("createRelationshipsForDestinationInstance:entityMapping:manager:error:")]
bool CreateRelationshipsForDestinationInstance (NSManagedObject dInstance, NSEntityMapping mapping, NSMigrationManager manager, out NSError error);
[Export ("endRelationshipCreationForEntityMapping:manager:error:")]
bool EndRelationshipCreationForEntityMapping (NSEntityMapping mapping, NSMigrationManager manager, out NSError error);
[Export ("performCustomValidationForEntityMapping:manager:error:")]
bool PerformCustomValidationForEntityMapping (NSEntityMapping mapping, NSMigrationManager manager, out NSError error);
[Export ("endEntityMapping:manager:error:")]
bool EndEntityMapping (NSEntityMapping mapping, NSMigrationManager manager, out NSError error);
}
[BaseType (typeof (NSPropertyDescription))]
interface NSExpressionDescription {
[NullAllowed, Export ("expression", ArgumentSemantic.Strong)]
NSExpression Expression { get; set; }
[Export ("expressionResultType")]
NSAttributeType ResultType { get; set; }
}
[BaseType (typeof (NSPropertyDescription))]
interface NSFetchedPropertyDescription {
[NullAllowed] // by default this property is null
[Export ("fetchRequest", ArgumentSemantic.Retain)]
NSFetchRequest FetchRequest { get; set; }
}
[DisableDefaultCtor]
[BaseType (typeof (NSExpression))]
interface NSFetchRequestExpression {
[Internal]
[DesignatedInitializer]
[Export ("initWithExpressionType:")]
NativeHandle Constructor (NSExpressionType type);
[Static, Export ("expressionForFetch:context:countOnly:")]
NSFetchRequestExpression FromFetch (NSExpression fetch, NSExpression context, bool countOnly);
[Export ("requestExpression")]
NSExpression Request { get; }
[Export ("contextExpression")]
NSExpression Context { get; }
[Export ("countOnlyRequest")]
bool IsCountOnly { [Bind ("isCountOnlyRequest")] get; }
}
interface INSFetchRequestResult { }
[MacCatalyst (13, 1)]
[Protocol]
interface NSFetchRequestResult { }
[DisableDefaultCtor] // designated
[BaseType (typeof (NSPersistentStoreRequest))]
interface NSFetchRequest : NSCoding {
[DesignatedInitializer]
[Export ("init")]
NativeHandle Constructor ();
[Export ("entity", ArgumentSemantic.Retain)]
[NullAllowed]
NSEntityDescription Entity { get; set; }
[Export ("predicate", ArgumentSemantic.Retain)]
[NullAllowed]
NSPredicate Predicate { get; set; }
[Export ("sortDescriptors", ArgumentSemantic.Retain)]
[NullAllowed]
NSSortDescriptor [] SortDescriptors { get; set; }
[Export ("fetchLimit")]
nuint FetchLimit { get; set; }
[Export ("fetchOffset")]
nuint FetchOffset { get; set; }
[Export ("affectedStores", ArgumentSemantic.Retain)]
[NullAllowed]
NSPersistentStore [] AffectedStores { get; set; }
[Export ("resultType")]
NSFetchRequestResultType ResultType { get; set; }
[Export ("returnsDistinctResults")]
bool ReturnsDistinctResults { get; set; }
[Export ("includesSubentities")]
bool IncludesSubentities { get; set; }
[Export ("includesPropertyValues")]
bool IncludesPropertyValues { get; set; }
[Export ("includesPendingChanges")]
bool IncludesPendingChanges { get; set; }
[Export ("returnsObjectsAsFaults")]
bool ReturnsObjectsAsFaults { get; set; }
[Export ("relationshipKeyPathsForPrefetching")]
[NullAllowed]
string [] RelationshipKeyPathsForPrefetching { get; set; }
[Export ("propertiesToFetch", ArgumentSemantic.Copy)]
[NullAllowed]
NSPropertyDescription [] PropertiesToFetch { get; set; }
[Static]
[Export ("fetchRequestWithEntityName:")]
// note: Xcode 6.3 changed the return value type from `NSFetchRequest*` to `instancetype`
NSFetchRequest FromEntityName (string entityName);
[Export ("initWithEntityName:")]
NativeHandle Constructor (string entityName);
[NullAllowed, Export ("entityName", ArgumentSemantic.Strong)]
string EntityName { get; }
[Export ("fetchBatchSize")]
nint FetchBatchSize { get; set; }
[Export ("shouldRefreshRefetchedObjects")]
bool ShouldRefreshRefetchedObjects { get; set; }
[Export ("havingPredicate", ArgumentSemantic.Retain)]
[NullAllowed]
NSPredicate HavingPredicate { get; set; }
[Export ("propertiesToGroupBy", ArgumentSemantic.Copy)]
[NullAllowed]
NSPropertyDescription [] PropertiesToGroupBy { get; set; }
[MacCatalyst (13, 1)]
[Export ("execute:")]
[return: NullAllowed]
INSFetchRequestResult [] Execute (out NSError error);
}
[NoMac]
[MacCatalyst (13, 1)]
[BaseType (typeof (NSObject), Delegates = new string [] { "WeakDelegate" })]
interface NSFetchedResultsController {
[Export ("initWithFetchRequest:managedObjectContext:sectionNameKeyPath:cacheName:")]
NativeHandle Constructor (NSFetchRequest fetchRequest, NSManagedObjectContext context, [NullAllowed] string sectionNameKeyPath, [NullAllowed] string name);
[Wrap ("WeakDelegate")]
INSFetchedResultsControllerDelegate Delegate { get; set; }
[Export ("delegate", ArgumentSemantic.Assign)]
[NullAllowed]
NSObject WeakDelegate { get; set; }
[NullAllowed, Export ("cacheName")]
string CacheName { get; }
[Export ("fetchedObjects")]
[NullAllowed]
NSObject [] FetchedObjects { get; }
[Export ("fetchRequest")]
NSFetchRequest FetchRequest { get; }
[Export ("managedObjectContext")]
NSManagedObjectContext ManagedObjectContext { get; }
[NullAllowed, Export ("sectionNameKeyPath")]
string SectionNameKeyPath { get; }
[NullAllowed, Export ("sections")]
INSFetchedResultsSectionInfo [] Sections { get; }
[Export ("performFetch:")]
bool PerformFetch (out NSError error);
[Export ("indexPathForObject:")]
[return: NullAllowed]
NSIndexPath FromObject (NSObject obj);
[Export ("objectAtIndexPath:")]
NSObject ObjectAt (NSIndexPath path);
[Export ("sectionForSectionIndexTitle:atIndex:")]
// name like UITableViewSource's similar (and linked) selector
nint SectionFor (string title, nint atIndex);
#if !NET
// badly named and conflict with the property
[Export ("sectionIndexTitleForSectionName:")]
[return: NullAllowed]
string SectionIndexTitles (string sectionName);
// expose a method as the property name is taken
[Export ("sectionIndexTitles")]
string [] GetSectionIndexTitles ();
#else
[Export ("sectionIndexTitleForSectionName:")]
[return: NullAllowed]
string GetSectionIndexTitle (string sectionName);
[Export ("sectionIndexTitles")]
string[] SectionIndexTitles { get; }
#endif
[Static]
[Export ("deleteCacheWithName:")]
void DeleteCache ([NullAllowed] string name);
}
interface INSFetchedResultsControllerDelegate { }
[NoMac]
[MacCatalyst (13, 1)]
[BaseType (typeof (NSObject))]
[Model]
[Protocol]
interface NSFetchedResultsControllerDelegate {
[Export ("controllerWillChangeContent:")]
void WillChangeContent (NSFetchedResultsController controller);
[Export ("controller:didChangeObject:atIndexPath:forChangeType:newIndexPath:")]
void DidChangeObject (NSFetchedResultsController controller, NSObject anObject, [NullAllowed] NSIndexPath indexPath, NSFetchedResultsChangeType type, [NullAllowed] NSIndexPath newIndexPath);
[Export ("controller:didChangeSection:atIndex:forChangeType:")]
void DidChangeSection (NSFetchedResultsController controller, INSFetchedResultsSectionInfo sectionInfo, nuint sectionIndex, NSFetchedResultsChangeType type);
[Export ("controllerDidChangeContent:")]
void DidChangeContent (NSFetchedResultsController controller);
[Export ("controller:sectionIndexTitleForSectionName:")]
[return: NullAllowed]
string SectionFor (NSFetchedResultsController controller, string sectionName);
}
[NoMac]
[MacCatalyst (13, 1)]
[BaseType (typeof (NSObject))]
[Model]
[Protocol]
interface NSFetchedResultsSectionInfo {
[Export ("numberOfObjects")]
[Abstract]
nint Count { get; }
[NullAllowed, Export ("objects")]
[Abstract]
NSObject [] Objects { get; }
[Export ("name")]
[Abstract]
string Name { get; }
[NullAllowed, Export ("indexTitle")]
[Abstract]
string IndexTitle { get; }
}
interface INSFetchedResultsSectionInfo { }
// NSInvalidArgumentException *** -loadMetadata: cannot be sent to an abstract object of class NSIncrementalStore: Create a concrete instance!
// Apple doc quote: "NSIncrementalStore is an abstract superclass..."
#if NET
// Making a class abstract has problems: https://github.com/xamarin/xamarin-macios/issues/4969, so we're not doing this yet
// [Abstract] // Abstract superclass.
#endif
[BaseType (typeof (NSPersistentStore))]
interface NSIncrementalStore {
#if NET
[Protected]
#endif
[Export ("initWithPersistentStoreCoordinator:configurationName:URL:options:")]
NativeHandle Constructor (NSPersistentStoreCoordinator root, string name, NSUrl url, NSDictionary options);
[Export ("loadMetadata:")]
bool LoadMetadata (out NSError error);
[Export ("executeRequest:withContext:error:")]
[return: NullAllowed]
NSObject ExecuteRequest (NSPersistentStoreRequest request, [NullAllowed] NSManagedObjectContext context, out NSError error);
[Export ("newValuesForObjectWithID:withContext:error:")]
[return: NullAllowed]
NSIncrementalStoreNode NewValues (NSManagedObjectID forObjectId, NSManagedObjectContext context, out NSError error);
[Export ("newValueForRelationship:forObjectWithID:withContext:error:")]
[return: NullAllowed]
NSObject NewValue (NSRelationshipDescription forRelationship, NSManagedObjectID forObjectI, [NullAllowed] NSManagedObjectContext context, out NSError error);
[Static]
[Export ("identifierForNewStoreAtURL:")]
#if NET
NSObject GetIdentifierForNewStore (NSUrl storeUrl);
#else
NSObject IdentifierForNewStoreAtURL (NSUrl storeUrl);
#endif
[Export ("obtainPermanentIDsForObjects:error:")]
[return: NullAllowed]
NSObject [] ObtainPermanentIds (NSObject [] array, out NSError error);
[Export ("managedObjectContextDidRegisterObjectsWithIDs:")]
void ManagedObjectContextDidRegisterObjectsWithIds (NSObject [] objectIds);
[Export ("managedObjectContextDidUnregisterObjectsWithIDs:")]
void ManagedObjectContextDidUnregisterObjectsWithIds (NSObject [] objectIds);
[Export ("newObjectIDForEntity:referenceObject:")]
NSManagedObjectID NewObjectIdFor (NSEntityDescription forEntity, NSObject referenceObject);
[Export ("referenceObjectForObjectID:")]
NSObject ReferenceObjectForObject (NSManagedObjectID objectId);
}
[BaseType (typeof (NSObject))]
interface NSIncrementalStoreNode {
[Export ("initWithObjectID:withValues:version:")]
#if XAMCORE_5_0
NativeHandle Constructor (NSManagedObjectID objectId, NSDictionary<NSString, NSObject> values, ulong version);
#else
NativeHandle Constructor (NSManagedObjectID objectId, NSDictionary values, ulong version);
#endif
[Export ("updateWithValues:version:")]
#if XAMCORE_5_0
void Update (NSDictionary<NSString, NSObject> values, ulong version);
#else
void Update (NSDictionary values, ulong version);
#endif
[Export ("objectID")]
NSManagedObjectID ObjectId { get; }
[Export ("version")]
long Version { get; }
[Export ("valueForPropertyDescription:")]
[return: NullAllowed]
NSObject ValueForPropertyDescription (NSPropertyDescription prop);
}
[BaseType (typeof (NSObject))]
// 'init' issues a warning: CoreData: error: Failed to call designated initializer on NSManagedObject class 'NSManagedObject'
// then crash while disposing the instance
[DisableDefaultCtor]
interface NSManagedObject : NSFetchRequestResult {
[DesignatedInitializer]
[Export ("initWithEntity:insertIntoManagedObjectContext:")]
NativeHandle Constructor (NSEntityDescription entity, [NullAllowed] NSManagedObjectContext context);
[MacCatalyst (13, 1)]
[Export ("initWithContext:")]
NativeHandle Constructor (NSManagedObjectContext moc);
[MacCatalyst (13, 1)]
[Static]
[Export ("entity")]
NSEntityDescription GetEntityDescription ();
[MacCatalyst (13, 1)]
[Static]
[Export ("fetchRequest")]
NSFetchRequest CreateFetchRequest ();
[NullAllowed, Export ("managedObjectContext")]
NSManagedObjectContext ManagedObjectContext { get; }
[Export ("entity", ArgumentSemantic.Strong)]
NSEntityDescription Entity { get; }
[Export ("objectID", ArgumentSemantic.Strong)]
NSManagedObjectID ObjectID { get; }
[Static, Export ("contextShouldIgnoreUnmodeledPropertyChanges")]
bool ContextShouldIgnoreUnModeledPropertyChanges { get; }
[Export ("inserted")]
bool IsInserted { [Bind ("isInserted")] get; }
[Export ("updated")]
bool IsUpdated { [Bind ("isUpdated")] get; }
[Export ("deleted")]
bool IsDeleted { [Bind ("isDeleted")] get; }
[Export ("fault")]
bool IsFault { [Bind ("isFault")] get; }
[Export ("faultingState")]
nuint FaultingState { get; }
[Export ("hasFaultForRelationshipNamed:")]
bool HasFaultForRelationshipNamed (string key);
[Export ("willAccessValueForKey:")]
void WillAccessValueForKey ([NullAllowed] string key);
[Export ("didAccessValueForKey:")]
void DidAccessValueForKey ([NullAllowed] string key);
[Export ("willChangeValueForKey:")]
void WillChangeValueForKey (string key);
[Export ("didChangeValueForKey:")]
void DidChangeValueForKey (string key);
[Export ("willChangeValueForKey:withSetMutation:usingObjects:")]
void WillChangeValueForKey (string inKey, NSKeyValueSetMutationKind inMutationKind, NSSet inObjects);
[Export ("didChangeValueForKey:withSetMutation:usingObjects:")]
void DidChangeValueForKey (string inKey, NSKeyValueSetMutationKind inMutationKind, NSSet inObjects);
[NoWatch]
[NoTV]
[MacCatalyst (13, 1)]
[Export ("observationInfo")]
IntPtr ObservationInfo { get; set; }
[Export ("awakeFromFetch")]
void AwakeFromFetch ();
[Export ("awakeFromInsert")]
void AwakeFromInsert ();
[Export ("awakeFromSnapshotEvents:")]
void AwakeFromSnapshotEvents (NSSnapshotEventType flags);
[Export ("willSave")]
void WillSave ();
[Export ("didSave")]
void DidSave ();
[Export ("willTurnIntoFault")]
void WillTurnIntoFault ();
[Export ("didTurnIntoFault")]
void DidTurnIntoFault ();
[Export ("valueForKey:")]
[return: NullAllowed]
#if NET
NSObject GetValue (string key);
#else
IntPtr ValueForKey (string key);
#endif
[Export ("setValue:forKey:")]
#if NET
void SetValue ([NullAllowed] NSObject value, string key);
#else
void SetValue (IntPtr value, string key);
#endif
[Export ("primitiveValueForKey:")]
[return: NullAllowed]
#if NET
NSObject GetPrimitiveValue (string key);
#else
IntPtr PrimitiveValueForKey (string key);
#endif
[Export ("setPrimitiveValue:forKey:")]
#if NET
void SetPrimitiveValue ([NullAllowed] NSObject value, string key);
#else
void SetPrimitiveValue (IntPtr value, string key);
#endif
[Export ("committedValuesForKeys:")]
#if XAMCORE_5_0
NSDictionary<NSString, NSObject> GetCommittedValues ([NullAllowed] string[] keys);
#elif NET
NSDictionary GetCommittedValues ([NullAllowed] string[] keys);
#else
NSDictionary CommittedValuesForKeys ([NullAllowed] string [] keys);
#endif
[Export ("changedValues")]
#if XAMCORE_5_0
NSDictionary<NSString, NSObject> ChangedValues { get; }
#else
NSDictionary ChangedValues { get; }
#endif
[Export ("validateValue:forKey:error:")]
bool ValidateValue (ref NSObject value, string key, out NSError error);
[Export ("validateForDelete:")]
bool ValidateForDelete (out NSError error);
[Export ("validateForInsert:")]
bool ValidateForInsert (out NSError error);
[Export ("validateForUpdate:")]
bool ValidateForUpdate (out NSError error);
[Export ("hasChanges")]
bool HasChanges { get; }
[Export ("changedValuesForCurrentEvent")]
NSDictionary ChangedValuesForCurrentEvent { get; }
[Export ("prepareForDeletion")]
void PrepareForDeletion ();
// headers say this is introduced in 7.0,10.9 but Xcode 7 API diff
// indicates it's new in 9.0,10.11... going by the header value...
[MacCatalyst (13, 1)]
[Export ("hasPersistentChangedValues")]
bool HasPersistentChangedValues { get; }
[MacCatalyst (13, 1)]
[Export ("objectIDsForRelationshipNamed:")]
NSManagedObjectID [] GetObjectIDs (string relationshipName);
}
[MacCatalyst (13, 1)]
[BaseType (typeof (NSObject))]
interface NSQueryGenerationToken : NSSecureCoding, NSCopying {
[Static, Export ("currentQueryGenerationToken", ArgumentSemantic.Strong)]
NSQueryGenerationToken CurrentToken { get; }
}
[BaseType (typeof (NSObject))]
[DisableDefaultCtor]
interface NSManagedObjectContext : NSCoding
#if !WATCH && !TVOS
, NSLocking
#endif
#if MONOMAC
, NSEditor, NSEditorRegistration
#endif
{
[Deprecated (PlatformName.iOS, 9, 0, message: "Use 'NSManagedObjectContext (NSManagedObjectContextConcurrencyType)' instead.")]
[Deprecated (PlatformName.TvOS, 9, 0, message: "Use 'NSManagedObjectContext (NSManagedObjectContextConcurrencyType)' instead.")]
[Deprecated (PlatformName.MacOSX, 10, 11, message: "Use 'NSManagedObjectContext (NSManagedObjectContextConcurrencyType)' instead.")]
[Deprecated (PlatformName.MacCatalyst, 13, 1, message: "Use 'NSManagedObjectContext (NSManagedObjectContextConcurrencyType)' instead.")]
[Export ("init")]
NativeHandle Constructor ();
[NullAllowed] // by default this property is null
[Export ("persistentStoreCoordinator", ArgumentSemantic.Retain)]
NSPersistentStoreCoordinator PersistentStoreCoordinator { get; set; }
[Export ("undoManager", ArgumentSemantic.Retain)]
[NullAllowed]
NSUndoManager UndoManager { get; set; }
[Export ("hasChanges")]
bool HasChanges { get; }
[Export ("objectRegisteredForID:")]
[return: NullAllowed]
NSManagedObject ObjectRegisteredForID (NSManagedObjectID objectID);
[Export ("objectWithID:")]
NSManagedObject ObjectWithID (NSManagedObjectID objectID);
[Export ("executeFetchRequest:error:")]
[return: NullAllowed]
NSObject [] ExecuteFetchRequest (NSFetchRequest request, out NSError error);
[Export ("countForFetchRequest:error:")]
nuint CountForFetchRequest (NSFetchRequest request, out NSError error);
[Export ("insertObject:")]
void InsertObject (NSManagedObject object1);
[Export ("deleteObject:")]
void DeleteObject (NSManagedObject object1);
[Export ("refreshObject:mergeChanges:")]
void RefreshObject (NSManagedObject object1, bool flag);
[Export ("detectConflictsForObject:")]