forked from apple/swift
/
Foundation.h
1023 lines (806 loc) · 35.2 KB
/
Foundation.h
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
#if __has_feature(modules)
@import ObjectiveC;
@import CoreFoundation;
@import CoreGraphics;
#else
#import <objc/NSObject.h>
#import <CoreFoundation.h>
#import <CoreGraphics.h>
#endif
#define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer))
typedef struct objc_object { void *isa; } *id;
typedef struct _NSZone NSZone;
void *allocate(NSZone *zone);
typedef double NSTimeInterval;
typedef struct _NSRange {
NSUInteger location;
NSUInteger length;
} NSRange;
extern NSUInteger NSRealMemoryAvailable(void) __attribute__((availability(macosx,introduced=10.0 ,deprecated=10.8,message="" ))) __attribute__((availability(ios,introduced=2.0 ,deprecated=6.0,message="" )));
extern NSUInteger SomeCrazyAppExtensionForbiddenAPI(void)
__attribute__((availability(macosx_app_extension,unavailable,message="Not available in App Extensions")))
__attribute__((availability(ios_app_extension,unavailable,message="Not available in App Extensions")));
extern NSString *const globalStringAvailableOn10_51 __attribute__((availability(macosx,introduced=10.51)));
extern NSString *const globalStringAvailableOn10_52 __attribute__((availability(macosx,introduced=10.52)));
__attribute__((availability(macosx,introduced=10.51)))
@interface NSAvailableOn10_51 : NSObject
- (instancetype)init;
- (instancetype)initWithStringOn10_52:(NSString *)s __attribute__((availability(macosx,introduced=10.52)));
@property NSInteger propertyOn10_52 __attribute__((availability(macosx,introduced=10.52)));
- (void)methodAvailableOn10_52 __attribute__((availability(macosx,introduced=10.52)));
@end
extern NSAvailableOn10_51 *const globalClassInstanceAvailableOn10_51 __attribute__((availability(macosx,introduced=10.51)));
__attribute__((availability(macosx,introduced=10.51)))
@protocol NSProtocolAvailableOn10_51
@end
__attribute__((availability(macosx,introduced=10.9)))
@interface NSAvailableOn10_9 : NSObject
@property NSInteger propertyOn10_9;
// Properties with unavailable accessors declared before property.
- (void)setPropertyOn10_51WithSetterOn10_52Before:(NSInteger)prop __attribute__((availability(macosx,introduced=10.52)));
@property NSInteger propertyOn10_51WithSetterOn10_52Before __attribute__((availability(macosx,introduced=10.51)));
- (NSInteger)propertyOn10_51WithGetterOn10_52Before __attribute__((availability(macosx,introduced=10.52)));
@property NSInteger propertyOn10_51WithGetterOn10_52Before __attribute__((availability(macosx,introduced=10.51)));
// Properties with unavailable accessors declared after property.
@property NSInteger propertyOn10_51WithSetterOn10_52After __attribute__((availability(macosx,introduced=10.51)));
- (void)setPropertyOn10_51WithSetterOn10_52After:(NSInteger)prop __attribute__((availability(macosx,introduced=10.52)));
@property NSInteger propertyOn10_51WithGetterOn10_52After __attribute__((availability(macosx,introduced=10.51)));
- (NSInteger)propertyOn10_51WithGetterOn10_52After __attribute__((availability(macosx,introduced=10.52)));
// Property with redeclared with a setter in a category
@property(readonly) NSInteger readOnlyRedeclaredWithSetterInCategory __attribute__((availability(macosx,introduced=10.51)));
- (void)methodAvailableOn10_52 __attribute__((availability(macosx,introduced=10.52)));
@end
@interface NSAvailableOn10_9 (NSWithPropertyReclarationInACategory)
@property(readwrite) NSInteger readOnlyRedeclaredWithSetterInCategory __attribute__((availability(macosx,introduced=10.51)));
- (void)setReadOnlyRedeclaredWithSetterInCategory:(NSInteger)prop __attribute__((availability(macosx,introduced=10.52)));
@end
/// Aaa. NSAvailableOnOSX10_51AndIOS8_0. Bbb.
__attribute__((availability(macosx,introduced=10.51)))
__attribute__((availability(ios,introduced=8.0)))
@interface NSAvailableOnOSX10_51AndIOS8_0 : NSObject
@end
@class NSString, NSArray, NSDictionary, NSSet, NSEnumerator;
@class NSMutableArray<ObjectType>;
/// Aaa. NSArray. Bbb.
@interface NSArray<ObjectType> : NSObject
- (nonnull ObjectType)objectAtIndexedSubscript:(NSUInteger)idx;
- description;
+ (instancetype)arrayWithObjects:(const ObjectType __nonnull [__nullable])objects count:(NSUInteger)count;
- (void)makeObjectsPerformSelector:(nonnull SEL)aSelector;
- (void)makeObjectsPerformSelector:(nonnull SEL)aSelector withObject:(nullable ObjectType)anObject;
- (void)makeObjectsPerformSelector:(nonnull SEL)aSelector withObject:(nullable ObjectType)anObject withObject:(nullable ObjectType)anotherObject;
- (nonnull NSMutableArray<ObjectType> *)mutableCopy;
@end
@interface NSArray (AddingObject)
- (NSInteger)indexOfObject:(nonnull id)object;
@end
@interface DummyClass : NSObject
- (nonnull id)objectAtIndexedSubscript:(NSUInteger)idx;
- description;
@property NSString *nsstringProperty;
@property BOOL boolProperty;
@property NSArray *arrayProperty;
@property NSDictionary *dictProperty;
@property NSSet *setProperty;
@end
@interface DummyClass (Extras)
@property NSString *nsstringProperty2;
@end
@interface NSCoder : NSObject
@end
@protocol NSCoding
- (nullable instancetype)initWithCoder:(nonnull NSCoder *)aCoder;
@end
@protocol NSSecureCoding <NSCoding>
@end
@protocol NSCopying
- (id)copyWithZone:(nullable NSZone *)zone;
@end
@interface NSDictionary<KeyType : id<NSCopying>, ObjectType> : NSObject /*<NSCopying, NSMutableCopying, NSSecureCoding, NSFastEnumeration>*/
@property (readonly) NSUInteger count;
- (nullable ObjectType)objectForKey:(nonnull KeyType)aKey;
- (nonnull NSEnumerator *)keyEnumerator;
@end
@interface NSDictionary<KeyType, ObjectType> (NSExtendedDictionary)
- (nullable ObjectType)objectForKeyedSubscript:(nonnull KeyType)key;
@end
@interface NSDictionary (Inits)
- (nonnull instancetype)init;
@end
@interface NSMutableDictionary<KeyType : id<NSCopying>, ObjectType> : NSDictionary<KeyType, ObjectType>
- (void)removeObjectForKey:(nonnull KeyType)aKey;
- (void)setObject:(nonnull ObjectType)anObject forKey:(nonnull KeyType)aKey;
@end
@interface NSMutableDictionary<KeyType, ObjectType> (NSExtendedMutableDictionary)
- (void)setObject:(nullable ObjectType)obj forKeyedSubscript:(nonnull KeyType)key;
@end
@interface NSSet<KeyType> : NSObject
- (nonnull instancetype)init;
- (NSUInteger)count;
- (nonnull KeyType)anyObject;
- (nonnull instancetype)initWithArray:(nonnull NSArray<KeyType> *)array;
@end
@interface NSMutableSet<KeyType> : NSSet<KeyType>
- (void)addObject:(KeyType)obj;
- (void)removeObject:(KeyType)obj;
@end
@interface NSCountedSet<KeyType> : NSMutableSet<KeyType>
- (instancetype)initWithCapacity:(NSUInteger)numItems NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithArray:(NSArray<KeyType> *)array;
@end
@interface NSValue : NSObject <NSCopying>
@end
@interface NSValue (NSRange)
+ (NSValue *)valueWithRange:(NSRange)range;
@property NSRange rangeValue;
@end
typedef __INT32_TYPE__ int32_t;
@interface NSNumber : NSValue
+ (nonnull NSNumber *)numberWithInt:(int)value;
+ (nonnull NSNumber *)numberWithInteger:(NSInteger)value;
+ (nonnull NSNumber *)numberWithUnsignedInteger:(NSUInteger)value;
+ (nonnull NSNumber *)numberWithDouble:(double)value;
- (nonnull NSNumber *)initWithInteger:(NSInteger)value;
- (nonnull NSNumber *)initWithUnsignedInteger:(NSUInteger)value;
- (nonnull NSNumber *)initWithDouble:(double)value;
- (nonnull NSNumber *)addDouble:(double)value;
- (nonnull NSNumber *)addBool:(BOOL)value;
- (nonnull NSNumber *)addUInt16:(unsigned short)value;
- (nonnull NSNumber *)addInt:(int)value;
- (nonnull NSNumber *)subtractInt32:(int32_t)value;
@property NSInteger integerValue;
@property NSUInteger unsignedIntegerValue;
@end
@interface NSDecimalNumber : NSObject
+ (instancetype)initWithMantissa:(unsigned long long)mantissa exponent:(short)exponent isNegative:(BOOL)isNegative;
+ (NSDecimalNumber *)decimalNumberWithMantissa:(unsigned long long)mantissa exponent:(short)exponent isNegative:(BOOL)isNegative;
@end
@interface NSError : NSObject
@property (readonly, nonnull) NSString *domain;
@property (readonly) NSInteger code;
- (nonnull instancetype)initWithDomain:(nonnull NSString *)domain code:(NSInteger)code userInfo:(nullable NSDictionary *)userInfo;
@end
@interface NSString : NSObject <NSSecureCoding, NSCopying>
- (void)onlyOnNSString;
+ (instancetype)stringWithContentsOfFile:(NSString*)path error:(NSError**)error;
+ (instancetype)stringWithContentsOfFile:(NSString*)path encoding:(int)encoding error:(NSError**)error;
+ (instancetype)stringWithPath:(NSString*)path;
+ (nullable instancetype)stringWithPath:(NSString*)path encoding:(int)encoding;
@end
NSString *NSStringToNSString(NSString *str);
@interface Bee : NSObject
-(void)buzz;
@end
@interface Hive : NSObject {
Bee *queen;
}
- init;
- (instancetype)initWithCoder:(NSCoder *)aDecoder;
@property (nonnull) NSArray<Bee *> *bees;
@property (nullable) NSDictionary<NSString *, Bee *> *beesByName;
@property (nonnull) NSSet<Bee *> *allBees;
@property (nonnull) NSDictionary<id <NSCopying>, Bee *> *anythingToBees;
@property(getter=isMakingHoney) BOOL makingHoney;
@property(setter=assignGuard:) id guard;
+ (instancetype)hiveWithQueen:(Bee *)queen;
+ (instancetype)hiveWithFlakyQueen:(Bee *)queen error:(NSError **)error;
- (instancetype)visit;
@end
@interface NSMutableString : NSString
@end
@interface NSURL : NSObject
+ (instancetype)URLWithString:(NSString *)URLString;
@end
@interface NSAttributedString : NSString
- (NSAttributedString *)sliceAttributedString:(NSInteger)startIndex;
@end
BOOL BOOLtoBOOL(BOOL b);
typedef CGPoint NSPoint;
typedef CGSize NSSize;
typedef CGRect NSRect;
typedef NSPoint *NSPointArray;
@interface BadCollection
- (id)objectForKeyedSubscript:(id)key;
- (void)setObject:(id)object forKeyedSubscript:(NSString *)key;
@end
@interface BadCollectionParent
- (id)objectForKeyedSubscript:(NSString *)key;
@end
@interface BadCollectionChild : BadCollectionParent
- (void)setObject:(id)object forKeyedSubscript:(id)key;
@end
@interface ReadOnlyCollectionChild : BadCollectionParent
- (void)setObject:(id)object forKeyedSubscript:(id)key;
@end
//===---
// Enums.
//===---
#define NS_ENUM(_type, _name) CF_ENUM(_type, _name)
#define NS_OPTIONS(_type, _name) CF_OPTIONS(_type, _name)
/// Aaa. NSRuncingMode. Bbb.
typedef NS_ENUM(NSUInteger, NSRuncingMode) {
NSRuncingMince,
NSRuncingQuince
};
typedef NS_ENUM(int, NSUnderlyingType) {
NSUnderlyingTypeZim,
NSUnderlyingTypeZang,
NSUnderlyingTypeFoo = 11,
NSUnderlyingTypeBar = 22,
NSUnderlyingTypeBas
};
typedef NS_ENUM(unsigned, NSUnsignedUnderlyingTypeNegativeValue) {
NSNegativeOne = -1,
NSNegativeTwo = -2,
};
typedef NS_ENUM(NSInteger, NSPrefixWordBreak) {
NSPrefixWordBreakBanjo,
NSPrefixWordBreakBandana
};
typedef NS_ENUM(NSInteger, NSPrefixWordBreak2) {
NSPrefixWordBreakBarBas,
NSPrefixWordBreakBareBass,
};
typedef NS_ENUM(NSInteger, NSPrefixWordBreak3) {
NSPrefixWordBreak1Bob,
NSPrefixWordBreak1Ben,
};
typedef NS_ENUM(NSInteger, NSPrefixWordBreakCustom) {
PrefixWordBreakProblemCase __attribute__((swift_name("problemCase"))),
NSPrefixWordBreakDeprecatedGoodCase __attribute__((deprecated)),
};
typedef NS_ENUM(NSInteger, NSPrefixWordBreak2Custom) {
PrefixWordBreak2ProblemCase __attribute__((swift_name("problemCase"))),
PrefixWordBreak2DeprecatedBadCase __attribute__((deprecated)),
NSPrefixWordBreak2DeprecatedGoodCase __attribute__((deprecated)),
NSPrefixWordBreak2GoodCase,
};
typedef NS_ENUM(NSInteger, NSPrefixWordBreakReversedCustom) {
NSPrefixWordBreakReversedDeprecatedGoodCase __attribute__((deprecated)),
PrefixWordBreakReversedProblemCase __attribute__((swift_name("problemCase"))),
};
typedef NS_ENUM(NSInteger, NSPrefixWordBreakReorderedCustom) {
PrefixWordBreakReorderedProblemCase __attribute__((swift_name("problemCase"))),
NSPrefixWordBreakReorderedGoodCase,
PrefixWordBreakReorderedDeprecatedBadCase __attribute__((deprecated)),
NSPrefixWordBreakReorderedDeprecatedGoodCase __attribute__((deprecated)),
};
typedef NS_ENUM(NSInteger, NSPrefixWordBreakReordered2Custom) {
PrefixWordBreakReordered2DeprecatedBadCase __attribute__((deprecated)),
PrefixWordBreakReordered2ProblemCase __attribute__((swift_name("problemCase"))),
NSPrefixWordBreakReordered2GoodCase,
NSPrefixWordBreakReordered2DeprecatedGoodCase __attribute__((deprecated)),
};
typedef NS_ENUM(NSInteger, NSSwiftNameAllTheThings) {
NSSwiftNameAllTheThingsA __attribute__((swift_name("Foo"))),
NSSwiftNameAllTheThingsB __attribute__((swift_name("Bar"))),
};
typedef NS_ENUM(NSInteger, NSSwiftNameBad) {
NSSwiftNameBadA __attribute__((swift_name("class"))),
};
typedef NS_ENUM(NSInteger, NSSingleConstantEnum) {
NSSingleConstantValue,
};
typedef NS_ENUM(unsigned char, NSAliasesEnum) {
NSAliasesOriginal = 129,
NSAliasesBySameValue = 129,
NSAliasesByEquivalentValue = -127,
NSAliasesByName = NSAliasesOriginal,
NSAliasesDifferentValue = 2
};
NS_ENUM(NSInteger, NSMalformedEnumMissingTypedef) {
NSMalformedEnumMissingTypedefValue
};
typedef NS_ENUM(NSUInteger, NSNumberFormatterBehavior) {
NSNumberFormatterBehaviorDefault = 0,
NSNumberFormatterBehavior10_0 = 1000,
NSNumberFormatterBehavior10_4 = 1040,
};
typedef NS_ENUM(NSUInteger, NSPostingStyle) {
NSPostWhenIdle = 1,
NSPostASAP = 2,
NSPostNow = 3
};
typedef NS_ENUM(NSUInteger, NSXMLNodeKind) {
NSXMLInvalidKind = 0,
NSXMLDocumentKind,
NSXMLElementKind,
NSXMLAttributeKind,
NSXMLNamespaceKind,
NSXMLProcessingInstructionKind,
NSXMLCommentKind,
NSXMLTextKind,
NSXMLDTDKind __attribute__((swift_name("DTDKind"))),
NSXMLEntityDeclarationKind,
NSXMLAttributeDeclarationKind,
NSXMLElementDeclarationKind,
NSXMLNotationDeclarationKind
};
// From CoreFoundation
typedef CF_ENUM(NSInteger, CFURLPathStyle) {
kCFURLPOSIXPathStyle = 0,
kCFURLHFSPathStyle /*CF_ENUM_DEPRECATED(10_0, 10_9, 2_0, 7_0)*/,
kCFURLWindowsPathStyle
};
typedef CF_ENUM(NSInteger, CFURLOrUTI) {
kCFURLKind,
kCFUTIKind
};
typedef CF_ENUM(NSInteger, Magnitude) {
k0,
k1,
k2,
};
typedef CF_ENUM(NSInteger, MagnitudeWords) {
kZero,
kOne,
kTwo,
};
// Deliberately simple to test the overlay module.
enum {
NSUTF8StringEncoding = 8
};
/// Aaa. NSRuncingOptions. Bbb.
typedef NS_OPTIONS(NSUInteger, NSRuncingOptions) {
NSRuncingNone = 0,
NSRuncingEnableMince = 1,
NSRuncingEnableQuince = 2,
};
typedef NS_OPTIONS(NSUInteger, NSSingleOptions) {
NSSingleValue = 1,
};
// From CoreFoundation
typedef CF_OPTIONS(unsigned long, CFCalendarUnit) {
kCFCalendarUnitEra = (1UL << 1),
kCFCalendarUnitYear = (1UL << 2),
kCFCalendarUnitMonth = (1UL << 3),
kCFCalendarUnitDay = (1UL << 4),
kCFCalendarUnitHour = (1UL << 5),
kCFCalendarUnitMinute = (1UL << 6),
kCFCalendarUnitSecond = (1UL << 7),
kCFCalendarUnitWeek /*CF_ENUM_DEPRECATED(10_4, 10_51, 2_0, 8_0)*/ = (1UL << 8),
kCFCalendarUnitWeekday = (1UL << 9),
kCFCalendarUnitWeekdayOrdinal = (1UL << 10),
kCFCalendarUnitQuarter /*CF_ENUM_AVAILABLE(10_6, 4_0)*/ = (1UL << 11),
kCFCalendarUnitWeekOfMonth /*CF_ENUM_AVAILABLE(10_7, 5_0)*/ = (1UL << 12),
kCFCalendarUnitWeekOfYear /*CF_ENUM_AVAILABLE(10_7, 5_0)*/ = (1UL << 13),
kCFCalendarUnitYearForWeekOfYear /*CF_ENUM_AVAILABLE(10_7, 5_0)*/ = (1UL << 14),
};
// From Foundation
typedef NS_OPTIONS(NSUInteger, NSKeyValueObservingOptions) {
NSKeyValueObservingOptionNew = 0x01,
NSKeyValueObservingOptionOld = 0x02,
NSKeyValueObservingOptionInitial /*NS_ENUM_AVAILABLE(10_5, 2_0)*/ = 0x04,
NSKeyValueObservingOptionPrior /*NS_ENUM_AVAILABLE(10_5, 2_0)*/ = 0x08
};
#define NS_CALENDAR_ENUM_DEPRECATED(osx_in, osx_out, ios_in, ios_out, msg) \
__attribute__((availability(macosx, introduced=osx_in, deprecated=osx_out, message=msg))) \
__attribute__((availability(iphoneos, introduced=ios_in, deprecated=ios_out, message=msg)))
typedef NS_OPTIONS(NSUInteger, NSCalendarUnit) {
NSCalendarUnitEra = kCFCalendarUnitEra,
NSCalendarUnitYear = kCFCalendarUnitYear,
NSCalendarUnitMonth = kCFCalendarUnitMonth,
// snip
NSCalendarUnitCalendar = (1 << 20),
NSEraCalendarUnit NS_CALENDAR_ENUM_DEPRECATED(10_4, 10_9, 2_0, 7_0, "Use NSCalendarUnitEra instead") = NSCalendarUnitEra,
NSYearCalendarUnit NS_CALENDAR_ENUM_DEPRECATED(10_4, 10_9, 2_0, 7_0, "Use NSCalendarUnitYear instead") = NSCalendarUnitYear,
NSMonthCalendarUnit NS_CALENDAR_ENUM_DEPRECATED(10_4, 10_9, 2_0, 7_0, "Use NSCalendarUnitMonth instead") = NSCalendarUnitMonth,
// snip
NSCalendarCalendarUnit NS_CALENDAR_ENUM_DEPRECATED(10_7, 10_9, 4_0, 7_0, "Use NSCalendarUnitCalendar instead") = NSCalendarUnitCalendar,
};
typedef NS_OPTIONS(NSUInteger, NSCalendarUnitDeprecated) {
NSEraCalendarUnitDeprecated NS_CALENDAR_ENUM_DEPRECATED(10_4, 10_9, 2_0, 7_0, "Use NSCalendarUnitEra instead") = NSCalendarUnitEra,
NSYearCalendarUnitDeprecated NS_CALENDAR_ENUM_DEPRECATED(10_4, 10_9, 2_0, 7_0, "Use NSCalendarUnitYear instead") = NSCalendarUnitYear,
NSMonthCalendarUnitDeprecated NS_CALENDAR_ENUM_DEPRECATED(10_4, 10_9, 2_0, 7_0, "Use NSCalendarUnitMonth instead") = NSCalendarUnitMonth,
// snip
NSCalendarCalendarUnitDeprecated NS_CALENDAR_ENUM_DEPRECATED(10_7, 10_9, 4_0, 7_0, "Use NSCalendarUnitCalendar instead") = NSCalendarUnitCalendar,
};
typedef NS_OPTIONS(NSUInteger, NSOptionsAlsoGetSwiftName) {
ThisIsAnNSOptionsCaseWithSwiftName __attribute__((swift_name("Case"))) = 0x1
};
#define CF_SWIFT_UNAVAILABLE(_msg) __attribute__((availability(swift, unavailable, message=_msg)))
#define NS_SWIFT_UNAVAILABLE(_msg) CF_SWIFT_UNAVAILABLE(_msg)
typedef NS_ENUM(NSUInteger, NSRectEdge) {
NSRectEdgeMinX = 0,
NSRectEdgeMinY = 1,
NSRectEdgeMaxX = 2,
NSRectEdgeMaxY = 3,
NSMinXEdge NS_SWIFT_UNAVAILABLE("Use NSRectEdge.MinX instead") = NSRectEdgeMinX,
NSMinYEdge NS_SWIFT_UNAVAILABLE("Use NSRectEdge.MinY instead") = NSRectEdgeMinY,
NSMaxXEdge __attribute__((availability(swift, unavailable, message="Use NSRectEdge.MaxX instead"))) = NSRectEdgeMaxX,
NSMaxYEdge __attribute__((availability(swift, unavailable, message="Use NSRectEdge.MaxY instead"))) = NSRectEdgeMaxY,
};
// From CoreBluetooth
typedef NS_OPTIONS(NSInteger, CBCharacteristicProperties) {
CBCharacteristicPropertyBroadcast = 0x01,
CBCharacteristicPropertyRead = 0x02,
CBCharacteristicPropertyWriteWithoutResponse = 0x04,
CBCharacteristicPropertyWrite = 0x08,
CBCharacteristicPropertyNotify = 0x10,
CBCharacteristicPropertyIndicate = 0x20,
CBCharacteristicPropertyAuthenticatedSignedWrites = 0x40,
CBCharacteristicPropertyExtendedProperties = 0x80,
CBCharacteristicPropertyNotifyEncryptionRequired /*NS_ENUM_AVAILABLE(10_9, 6_0)*/ = 0x100,
CBCharacteristicPropertyIndicateEncryptionRequired /*NS_ENUM_AVAILABLE(10_9, 6_0)*/ = 0x200
};
// From CoreMedia
typedef CF_OPTIONS(unsigned int, CMTimeFlags) {
kCMTimeFlags_Valid = 1UL<<0,
kCMTimeFlags_HasBeenRounded = 1UL<<1,
kCMTimeFlags_PositiveInfinity = 1UL<<2,
kCMTimeFlags_NegativeInfinity = 1UL<<3,
kCMTimeFlags_Indefinite = 1UL<<4,
kCMTimeFlags_ImpliedValueFlagsMask = kCMTimeFlags_PositiveInfinity | kCMTimeFlags_NegativeInfinity | kCMTimeFlags_Indefinite
};
typedef CF_OPTIONS(unsigned int, CMTimeFlagsWithNumber) {
kCMTimeFlagsWithNumber_Valid = 1UL<<0,
kCMTimeFlagsWithNumber_888 = 1UL<<1,
};
// Contrived name with a plural "-es"...normally these are "beeps".
typedef NS_OPTIONS(NSInteger, AlertBuzzes) {
AlertBuzzNone = 0,
AlertBuzzFunk = 1 << 0,
AlertBuzzHero = 1 << 1,
AlertBuzzSosumi = 1 << 2
};
// From AppKit
typedef NS_OPTIONS(NSUInteger, NSBitmapFormat) {
NSAlphaFirstBitmapFormat = 1 << 0, // 0 means is alpha last (RGBA, CMYKA, etc.)
NSAlphaNonpremultipliedBitmapFormat = 1 << 1, // 0 means is premultiplied
NSFloatingPointSamplesBitmapFormat = 1 << 2, // 0 is integer
NS16BitLittleEndianBitmapFormat /*NS_ENUM_AVAILABLE_MAC(10_51)*/ = (1 << 8),
NS32BitLittleEndianBitmapFormat /*NS_ENUM_AVAILABLE_MAC(10_51)*/ = (1 << 9),
NS16BitBigEndianBitmapFormat /*NS_ENUM_AVAILABLE_MAC(10_51)*/ = (1 << 10),
NS32BitBigEndianBitmapFormat /*NS_ENUM_AVAILABLE_MAC(10_51)*/ = (1 << 11)
};
typedef NS_OPTIONS(NSUInteger, NSBitmapFormatReversed) {
NS16BitLittleEndianBitmapFormatR /*NS_ENUM_AVAILABLE_MAC(10_51)*/ = (1 << 8),
NS32BitLittleEndianBitmapFormatR /*NS_ENUM_AVAILABLE_MAC(10_51)*/ = (1 << 9),
NS16BitBigEndianBitmapFormatR /*NS_ENUM_AVAILABLE_MAC(10_51)*/ = (1 << 10),
NS32BitBigEndianBitmapFormatR /*NS_ENUM_AVAILABLE_MAC(10_51)*/ = (1 << 11),
NSAlphaFirstBitmapFormatR = 1 << 0, // 0 means is alpha last (RGBA, CMYKA, etc.)
NSAlphaNonpremultipliedBitmapFormatR = 1 << 1, // 0 means is premultiplied
NSFloatingPointSamplesBitmapFormatR = 1 << 2, // 0 is integer
};
typedef NS_OPTIONS(NSUInteger, NSBitmapFormat2) {
NSU16a = 1,
NSU32a = 2,
};
typedef NS_OPTIONS(NSUInteger, NSBitmapFormat3) {
NSU16b = 1,
NSU32b = 2,
NSS16b = 4,
NSS32b = 8,
};
typedef NS_OPTIONS(NSUInteger, NSUBitmapFormat4) {
NSU16c = 1,
NSU32c = 2,
};
typedef NS_OPTIONS(NSUInteger, NSABitmapFormat5) {
NSAA16d = 1,
NSAB32d = 2,
};
/// Aaa. NSPotentiallyUnavailableOptions. Bbb.
typedef NS_OPTIONS(NSUInteger, NSPotentiallyUnavailableOptions) {
NSPotentiallyUnavailableOptionsFirst = (1 << 0),
NSPotentiallyUnavailableOptionsSecond = (1 << 1),
NSPotentiallyUnavailableOptionsThird = (1 << 2),
} __attribute__((availability(macosx, introduced=10.51)));
/// Aaa. NSOptionsWithUnavailableElement. Bbb.
typedef NS_OPTIONS(NSUInteger, NSOptionsWithUnavailableElement) {
NSOptionsWithUnavailableElementFirst = (1 << 0),
NSOptionsWithUnavailableElementSecond = (1 << 1),
NSOptionsWithUnavailableElementThird __attribute__((availability(macosx, introduced=10.51))) = (1 << 2),
};
/// Aaa. NSUnavailableEnum. Bbb.
typedef NS_ENUM(NSUInteger, NSUnavailableEnum) {
NSUnavailableEnumFirst,
NSUnavailableEnumSecond,
NSUnavailableEnumThird,
} __attribute__((availability(macosx, introduced=10.51)));
/// Aaa. NSEnumWithUnavailableElement. Bbb.
typedef NS_ENUM(NSUInteger, NSEnumWithUnavailableElement) {
NSEnumWithUnavailableElementFirst,
NSEnumWithUnavailableElementSecond,
NSEnumWithUnavailableElementThird __attribute__((availability(macosx, introduced=10.51))),
};
typedef NS_OPTIONS(NSUInteger, NSDeprecatedOptions) {
NSDeprecatedOptionsNone = 0,
NSDeprecatedOptionsFirst = (1 << 0)
} __attribute__((availability(macosx, introduced=10.51, deprecated=10.51, message="Use a different API")));
typedef NS_ENUM(NSUInteger, NSDeprecatedEnum) {
NSDeprecatedEnumFirst
} __attribute__((availability(macosx, introduced=10.51, deprecated=10.51, message="Use a different API")));
typedef NS_OPTIONS(NSUInteger, NSExplicitlyUnavailableOptions) {
NSExplicitlyUnavailableOptionsNone = 0,
NSExplicitlyUnavailableOptionsFirst = (1 << 0)
} __attribute__((unavailable));
typedef NS_OPTIONS(NSUInteger, NSExplicitlyUnavailableOnOSXOptions) {
NSExplicitlyUnavailableOnOSXOptionsNone = 0,
NSExplicitlyUnavailableOnOSXOptionsFirst = (1 << 0)
} __attribute__((availability(macosx, unavailable, message="Use a different API")));
@interface NSClassWithDeprecatedOptionsInMethodSignature : NSObject
+ (NSClassWithDeprecatedOptionsInMethodSignature *) sharedInstance;
@end
@interface NSClassWithDeprecatedOptionsInMethodSignature (ActuallyUseOptions)
- (void)someMethodWithDeprecatedOptions:(NSDeprecatedOptions)options __attribute__((availability(macosx, introduced=10.51, deprecated=10.51, message="Use a different API")));
@end
@interface NSClassWithExplicitlyUnavailableOptionsInMethodSignature : NSObject
+ (NSClassWithExplicitlyUnavailableOptionsInMethodSignature *) sharedInstance;
@end
@interface NSClassWithExplicitlyUnavailableOptionsInMethodSignature (ActuallyUseOptions)
- (void)someMethodWithUnavailableOptions:(NSExplicitlyUnavailableOptions)options __attribute__((unavailable));
- (void)someMethodWithUnavailableOptionsOnOSX:(NSExplicitlyUnavailableOnOSXOptions)options __attribute__((availability(macosx, unavailable, message="Use a different API")));
@end
@interface NSClassWithPotentiallyUnavailableOptionsInMethodSignature : NSObject
+ (NSClassWithPotentiallyUnavailableOptionsInMethodSignature *) sharedInstance;
- (void)someMethodWithPotentiallyUnavailableOptions:(NSPotentiallyUnavailableOptions)options __attribute__((availability(macosx, introduced=10.52)));
@end
@protocol NSWobbling
-(void)wobble;
- (instancetype)returnMyself;
@optional
-(void)wibble;
- (id)objectAtIndexedSubscript:(NSUInteger)idx;
@end
@protocol NSMaybeInitWobble
@optional
- (id)initWithWobble:(int)wobble;
@end
@interface NSURLRequest : NSObject
+ (instancetype)requestWithString:(NSString *)URLString;
+ (instancetype)URLRequestWithURL:(NSURL *)URL;
@end
NS_SWIFT_UNAVAILABLE("NSInvocation and related APIs not available")
@interface NSInvocation : NSObject
@end
typedef NS_ENUM(NSInteger, NSByteCountFormatterCountStyle) {
NSByteCountFormatterCountStyleFile = 0,
NSByteCountFormatterCountStyleMemory = 1,
NSByteCountFormatterCountStyleDecimal = 2,
NSByteCountFormatterCountStyleBinary = 3
};
@interface NSByteCountFormatter : NSObject
@property NSByteCountFormatterCountStyle countStyle;
@end
NSArray *arrayToArray(NSArray *arr);
NSDictionary *dictToDict(NSDictionary *dict);
NSSet *setToSet(NSSet *dict);
@interface NSExtensionContext : NSObject
- (void)openURL:(NSURL *)URL completionHandler:(void (^)(BOOL success))completionHandler;
@end
@interface NSProcessInfo : NSObject
+ (nonnull NSProcessInfo *)processInfo;
@end
@interface NSString(FoundationExts)
- (void)notBridgedMethod;
@end
@interface NSString(FoundationExts)
@property (nonatomic, copy) NSString *uppercaseString;
@end
typedef struct {
unsigned long state;
id __unsafe_unretained *itemsPtr;
unsigned long *mutationsPtr;
unsigned long extra[5];
} NSFastEnumerationState;
@protocol NSFastEnumeration
- (NSUInteger)countByEnumeratingWithState:(nonnull NSFastEnumerationState *)state objects:(id __unsafe_unretained [])buffer count:(NSUInteger)len;
@end
typedef const void * CFTypeRef;
typedef const struct __attribute__((objc_bridge(NSString))) __CFString * CFStringRef;
typedef const struct __attribute__((objc_bridge(NSDictionary))) __CFDictionary * CFDictionaryRef;
typedef struct CGColor *CGColorRef;
extern CFTypeRef CFRetain(CFTypeRef cf);
extern void CFRelease(CFTypeRef cf);
extern CFTypeRef CFAutorelease(CFTypeRef __attribute__((cf_consumed)) arg) __attribute__((availability(macosx,introduced=10.9)));
extern CGColorRef CGColorRetain(CGColorRef color) __attribute__((availability(macosx,introduced=10.3)));
extern void CGColorRelease(CGColorRef color) __attribute__((availability(macosx,introduced=10.3)));
@interface NSObject (NSDistributedObjects)
@property (readonly) Class classForPortCoder NS_SWIFT_UNAVAILABLE("Use NSXPCConnection instead");
@end
typedef NSString *__nonnull NSNotificationName
__attribute((swift_newtype(struct)));
NS_SWIFT_UNAVAILABLE("Use NSXPCConnection instead")
extern NSString * const NSConnectionReplyMode;
NS_SWIFT_UNAVAILABLE("Use NSXPCConnection instead")
extern NSString * const NSConnectionDidDieNotification;
NS_SWIFT_UNAVAILABLE("Use NSXPCConnection instead")
@interface NSConnection : NSObject {
}
@end
NS_SWIFT_UNAVAILABLE("Use NSXPCConnection instead")
@interface NSPortCoder : NSCoder
@end
NS_SWIFT_UNAVAILABLE("Use NSXPCConnection instead")
@protocol NSConnectionDelegate <NSObject>
@end
NS_SWIFT_UNAVAILABLE("Use NSXPCConnection instead")
@interface NSDistantObjectRequest : NSObject
@end
NS_SWIFT_UNAVAILABLE("Use NSXPCConnection instead")
@interface NSDistantObject
@end
NS_SWIFT_UNAVAILABLE("Use NSXPCConnection instead")
@interface NSPortNameServer : NSObject
@end
NS_SWIFT_UNAVAILABLE("Use NSXPCConnection instead")
@interface NSMachBootstrapServer : NSPortNameServer
@end
NS_SWIFT_UNAVAILABLE("Use NSXPCConnection instead")
@interface NSMessagePortNameServer : NSPortNameServer
@end
NS_SWIFT_UNAVAILABLE("Use NSXPCConnection instead")
@interface NSSocketPortNameServer : NSPortNameServer
@end
NS_SWIFT_UNAVAILABLE("Use NSCalendar and NSDateComponents and NSDateFormatter instead")
@interface NSCalendarDate : NSDate
@end
NS_SWIFT_UNAVAILABLE("NSInvocation and related APIs not available")
@interface NSInvocationOperation : NSObject
@end
NS_SWIFT_UNAVAILABLE("NSInvocation and related APIs not available")
@interface NSMethodSignature : NSObject
@end
/// Unavailable Global Functions
extern void NSSetZoneName(NSZone * __nonnull zone, NSString * __nonnull name) NS_SWIFT_UNAVAILABLE("Zone-based memory management is unavailable");
extern NSString *NSZoneName(NSZone *zone) NS_SWIFT_UNAVAILABLE("Zone-based memory management is unavailable");
extern NSZone *NSCreateZone(NSUInteger startSize, NSUInteger granularity, BOOL canFree) NS_SWIFT_UNAVAILABLE("Zone-based memory management is unavailable");
@interface NSXPCInterface : NSObject
+ (NSXPCInterface *)interfaceWithProtocol:(Protocol *)protocol;
@end
typedef struct NonNilableReferences {
NSObject *__nonnull __unsafe_unretained obj;
} NonNilableReferences;
@protocol NSProtocolWithOptionalRequirement
@optional
-(void)optionalRequirement;
@end
@interface NSClassWithMethodFromNSProtocolWithOptionalRequirement
-(void)optionalRequirement __attribute__((availability(macosx, introduced=10.51)));
@end
__attribute__((availability(macosx,introduced=10.51)))
@interface AnnotatedFrameworkClass : NSObject
@end
__attribute__((availability(macosx,introduced=10.52)))
@interface AnnotatedLaterFrameworkClass : NSObject
@end
/// Aaa. UnannotatedFrameworkProtocol. Bbb.
@protocol UnannotatedFrameworkProtocol
-(void)doSomethingWithClass:(AnnotatedFrameworkClass * __nullable)k;
-(void)doSomethingWithNonNullableClass:(AnnotatedFrameworkClass * __nonnull)k;
-(void)doSomethingWithIUOClass:(AnnotatedFrameworkClass * __null_unspecified)k;
-(AnnotatedFrameworkClass * __nullable)returnSomething;
-(void)noUnavailableTypesInSignature;
-(void)doSomethingWithClass:(AnnotatedFrameworkClass * __nonnull)k andLaterClass:(AnnotatedLaterFrameworkClass * __nonnull)lk;
-(void)someMethodWithAvailability __attribute__((availability(macosx,introduced=10.53)));
@property(nonnull) AnnotatedFrameworkClass *someProperty;
@end
/// Aaa. AnnotatedFrameworkProtocol. Bbb.
__attribute__((availability(macosx,introduced=10.9)))
@protocol AnnotatedFrameworkProtocol
-(AnnotatedFrameworkClass * __nullable)returnSomething;
@end
/// Aaa. FrameworkClassConformingToUnannotatedFrameworkProtocol. Bbb.
@interface FrameworkClassConformingToUnannotatedFrameworkProtocol : NSObject <UnannotatedFrameworkProtocol>
@end
/// Aaa. LaterFrameworkClassConformingToUnannotatedFrameworkProtocol. Bbb.
__attribute__((availability(macosx,introduced=10.52)))
@interface LaterFrameworkClassConformingToUnannotatedFrameworkProtocol : NSObject <UnannotatedFrameworkProtocol>
@end
/// Aaa. LaterAnnotatedFrameworkProtocol. Bbb.
__attribute__((availability(macosx,introduced=10.52)))
@protocol LaterAnnotatedFrameworkProtocol
-(AnnotatedFrameworkClass * __nullable)returnSomething;
-(void)doSomethingWithClass:(AnnotatedFrameworkClass * __nonnull)k andLaterClass:(AnnotatedLaterFrameworkClass * __nonnull)lk;
-(void)noUnavailableTypesInSignature;
-(void)someMethodWithAvailability __attribute__((availability(macosx,introduced=10.53)));
@property(nonnull) AnnotatedFrameworkClass *someProperty;
@end
/// Aaa. FrameworkClassConformingToLaterAnnotatedFrameworkProtocol. Bbb.
@interface FrameworkClassConformingToLaterAnnotatedFrameworkProtocol : NSObject<LaterAnnotatedFrameworkProtocol>
@end
@interface UnusedResults : NSObject
-(NSInteger)producesResult __attribute__((warn_unused_result));
@end
@interface NSObject (Silly)
-(void)doSelector:(SEL)selector;
@end
@interface Bee (Gerunds)
- (void)startSquashingBee:(nonnull Bee *)bee;
- (void)startSoothingBee:(nonnull Bee *)bee;
- (void)startShoppingBee:(nonnull Bee *)bee;
@end
@interface NSMutableArray<ObjectType> : NSArray
- (void)addObjects:(nonnull NSArray<ObjectType> *)objects;
@end
@interface NSString (Slicing)
- (nonnull NSString *)sliceFromIndex:(NSInteger)fromIndex toIndex:(NSInteger)toIndex;
@end
@interface NSString (Appending)
- (nonnull NSString *)stringByAppendingString:(nonnull NSString *)string;
- (nonnull NSString *)stringWithString:(nonnull NSString *)string;
- (nullable NSURL *)URLWithAddedString:(nonnull NSString *)string;
+ (NSString *)stringForCalendarUnits:(NSCalendarUnit)units;
@end
@interface NSURL (Properties)
@property (readonly, nullable) NSURL *URLByDeletingLastPathComponent;
@property (readonly, nonnull) NSURL *URLWithHTTPS;
@end
typedef NS_OPTIONS(NSUInteger, NSEnumerationOptions) {
NSEnumerationConcurrent = (1UL << 0),
NSEnumerationReverse = (1UL << 1),
};
@interface NSArray (Enumeration)
- (void)enumerateObjectsUsingBlock:(void (^)(id obj,
NSUInteger idx,
BOOL *stop))block;
- (void)enumerateObjectsWithOptions:(NSEnumerationOptions)opts
usingBlock:(void (^)(id obj, NSUInteger idx,
BOOL *stop))block;
- (void)enumerateObjectsRandomlyWithBlock:(void (^ __nullable)(
id obj,
NSUInteger idx,
BOOL *stop))block;
- (void)enumerateObjectsHaphazardly:(void (^ __nullable)(id obj,
NSUInteger idx,
BOOL *stop))block;
- (void)optionallyEnumerateObjects:(NSEnumerationOptions)opts
body:(void (^)(id obj, NSUInteger idx,
BOOL *stop))block;
- (void)enumerateObjectsWhileOrderingPizza:(BOOL)pizza
withOptions:(NSEnumerationOptions)opts
usingBlock:(void (^)(id obj, NSUInteger idx,
BOOL *stop))block;
- (void)doSomethingWithCopying:(nonnull id<NSCopying>)copying;
- (void)doSomethingElseWithCopying:(nonnull NSObject<NSCopying> *)copying;
- (void)enumerateObjectsWithNullableBlock:(void (^ __nullable)(
id obj,
NSUInteger idx,
BOOL *stop))block;
@end
@interface NSMutableArray (Sorting)
- (void)sortUsingFunction:(NSInteger (* __nonnull)(__nonnull id, __nonnull id))fimctopn;
@end
@interface NSMutableArray (Removal)
- (void)removeObjects:(nonnull NSArray *)objects;
@end
@interface NSMutableArray (TypeSuffix)
- (void)doSomethingWithUnderlying:(NSUnderlyingType)underlying;
- (void)setDefaultEnumerationOptions:(NSEnumerationOptions)options;
@end
@interface NSString ()
- (nonnull NSString *)stringByNormalizingXMLPreservingComments:(BOOL)preserveFlag;
@end
@interface NSSet ()
- (nonnull NSSet *)setByAddingObject:(nonnull id)object;
@property (readonly) BOOL empty;
- (BOOL)nonEmpty;
@property (readonly) BOOL isStringSet;
@property (readonly) BOOL wantsAUnion;
@property (readonly) BOOL watchesItsLanguage;
@property (readonly) BOOL appliesForAJob;
@property (readonly) BOOL setShouldBeInfinite;
@end
int variadicFunc1(int A, ...);
int variadicFunc2(int A, ...);
@interface NSString (UTF8)
-(nullable instancetype)initWithUTF8String:(const char *)bytes;
@end