1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9extern_class!(
10 #[unsafe(super(NSObject))]
14 #[derive(PartialEq, Eq, Hash)]
15 pub struct NSArray<ObjectType: ?Sized = AnyObject>;
16);
17
18#[cfg(feature = "NSObject")]
19extern_conformance!(
20 unsafe impl<ObjectType: ?Sized + NSCoding> NSCoding for NSArray<ObjectType> {}
21);
22
23#[cfg(feature = "NSObject")]
24extern_conformance!(
25 unsafe impl<ObjectType: ?Sized> NSCopying for NSArray<ObjectType> {}
26);
27
28#[cfg(feature = "NSObject")]
29unsafe impl<ObjectType: ?Sized + Message> CopyingHelper for NSArray<ObjectType> {
30 type Result = Self;
31}
32
33#[cfg(feature = "NSEnumerator")]
34extern_conformance!(
35 unsafe impl<ObjectType: ?Sized> NSFastEnumeration for NSArray<ObjectType> {}
36);
37
38#[cfg(feature = "NSObject")]
39extern_conformance!(
40 unsafe impl<ObjectType: ?Sized> NSMutableCopying for NSArray<ObjectType> {}
41);
42
43#[cfg(feature = "NSObject")]
44unsafe impl<ObjectType: ?Sized + Message> MutableCopyingHelper for NSArray<ObjectType> {
45 type Result = NSMutableArray<ObjectType>;
46}
47
48extern_conformance!(
49 unsafe impl<ObjectType: ?Sized> NSObjectProtocol for NSArray<ObjectType> {}
50);
51
52#[cfg(feature = "NSObject")]
53extern_conformance!(
54 unsafe impl<ObjectType: ?Sized + NSSecureCoding> NSSecureCoding for NSArray<ObjectType> {}
55);
56
57impl<ObjectType: Message> NSArray<ObjectType> {
58 extern_methods!(
59 #[unsafe(method(count))]
60 #[unsafe(method_family = none)]
61 pub fn count(&self) -> NSUInteger;
62
63 #[unsafe(method(objectAtIndex:))]
64 #[unsafe(method_family = none)]
65 pub fn objectAtIndex(&self, index: NSUInteger) -> Retained<ObjectType>;
66
67 #[unsafe(method(init))]
68 #[unsafe(method_family = init)]
69 pub fn init(this: Allocated<Self>) -> Retained<Self>;
70
71 #[unsafe(method(initWithObjects:count:))]
72 #[unsafe(method_family = init)]
73 pub unsafe fn initWithObjects_count(
74 this: Allocated<Self>,
75 objects: *mut NonNull<ObjectType>,
76 cnt: NSUInteger,
77 ) -> Retained<Self>;
78
79 #[cfg(feature = "NSCoder")]
80 #[unsafe(method(initWithCoder:))]
81 #[unsafe(method_family = init)]
82 pub unsafe fn initWithCoder(
83 this: Allocated<Self>,
84 coder: &NSCoder,
85 ) -> Option<Retained<Self>>;
86 );
87}
88
89impl<ObjectType: Message> NSArray<ObjectType> {
91 extern_methods!(
92 #[unsafe(method(new))]
93 #[unsafe(method_family = new)]
94 pub fn new() -> Retained<Self>;
95 );
96}
97
98impl<ObjectType: Message> DefaultRetained for NSArray<ObjectType> {
99 #[inline]
100 fn default_retained() -> Retained<Self> {
101 Self::new()
102 }
103}
104
105#[repr(transparent)]
108#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
109pub struct NSBinarySearchingOptions(pub NSUInteger);
110bitflags::bitflags! {
111 impl NSBinarySearchingOptions: NSUInteger {
112 #[doc(alias = "NSBinarySearchingFirstEqual")]
113 const FirstEqual = 1<<8;
114 #[doc(alias = "NSBinarySearchingLastEqual")]
115 const LastEqual = 1<<9;
116 #[doc(alias = "NSBinarySearchingInsertionIndex")]
117 const InsertionIndex = 1<<10;
118 }
119}
120
121unsafe impl Encode for NSBinarySearchingOptions {
122 const ENCODING: Encoding = NSUInteger::ENCODING;
123}
124
125unsafe impl RefEncode for NSBinarySearchingOptions {
126 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
127}
128
129impl<ObjectType: Message> NSArray<ObjectType> {
131 extern_methods!(
132 #[unsafe(method(arrayByAddingObject:))]
133 #[unsafe(method_family = none)]
134 pub unsafe fn arrayByAddingObject(
135 &self,
136 an_object: &ObjectType,
137 ) -> Retained<NSArray<ObjectType>>;
138
139 #[unsafe(method(arrayByAddingObjectsFromArray:))]
140 #[unsafe(method_family = none)]
141 pub unsafe fn arrayByAddingObjectsFromArray(
142 &self,
143 other_array: &NSArray<ObjectType>,
144 ) -> Retained<NSArray<ObjectType>>;
145
146 #[cfg(feature = "NSString")]
147 #[unsafe(method(componentsJoinedByString:))]
148 #[unsafe(method_family = none)]
149 pub unsafe fn componentsJoinedByString(&self, separator: &NSString) -> Retained<NSString>;
150
151 #[unsafe(method(containsObject:))]
152 #[unsafe(method_family = none)]
153 pub unsafe fn containsObject(&self, an_object: &ObjectType) -> bool;
154
155 #[cfg(feature = "NSString")]
156 #[unsafe(method(description))]
157 #[unsafe(method_family = none)]
158 pub unsafe fn description(&self) -> Retained<NSString>;
159
160 #[cfg(feature = "NSString")]
161 #[unsafe(method(descriptionWithLocale:))]
162 #[unsafe(method_family = none)]
163 pub unsafe fn descriptionWithLocale(
164 &self,
165 locale: Option<&AnyObject>,
166 ) -> Retained<NSString>;
167
168 #[cfg(feature = "NSString")]
169 #[unsafe(method(descriptionWithLocale:indent:))]
170 #[unsafe(method_family = none)]
171 pub unsafe fn descriptionWithLocale_indent(
172 &self,
173 locale: Option<&AnyObject>,
174 level: NSUInteger,
175 ) -> Retained<NSString>;
176
177 #[unsafe(method(firstObjectCommonWithArray:))]
178 #[unsafe(method_family = none)]
179 pub unsafe fn firstObjectCommonWithArray(
180 &self,
181 other_array: &NSArray<ObjectType>,
182 ) -> Option<Retained<ObjectType>>;
183
184 #[cfg(feature = "NSRange")]
185 #[unsafe(method(getObjects:range:))]
186 #[unsafe(method_family = none)]
187 pub unsafe fn getObjects_range(
188 &self,
189 objects: NonNull<NonNull<ObjectType>>,
190 range: NSRange,
191 );
192
193 #[unsafe(method(indexOfObject:))]
194 #[unsafe(method_family = none)]
195 pub unsafe fn indexOfObject(&self, an_object: &ObjectType) -> NSUInteger;
196
197 #[cfg(feature = "NSRange")]
198 #[unsafe(method(indexOfObject:inRange:))]
199 #[unsafe(method_family = none)]
200 pub unsafe fn indexOfObject_inRange(
201 &self,
202 an_object: &ObjectType,
203 range: NSRange,
204 ) -> NSUInteger;
205
206 #[unsafe(method(indexOfObjectIdenticalTo:))]
207 #[unsafe(method_family = none)]
208 pub unsafe fn indexOfObjectIdenticalTo(&self, an_object: &ObjectType) -> NSUInteger;
209
210 #[cfg(feature = "NSRange")]
211 #[unsafe(method(indexOfObjectIdenticalTo:inRange:))]
212 #[unsafe(method_family = none)]
213 pub unsafe fn indexOfObjectIdenticalTo_inRange(
214 &self,
215 an_object: &ObjectType,
216 range: NSRange,
217 ) -> NSUInteger;
218
219 #[unsafe(method(isEqualToArray:))]
220 #[unsafe(method_family = none)]
221 pub unsafe fn isEqualToArray(&self, other_array: &NSArray<ObjectType>) -> bool;
222
223 #[unsafe(method(firstObject))]
224 #[unsafe(method_family = none)]
225 pub fn firstObject(&self) -> Option<Retained<ObjectType>>;
226
227 #[unsafe(method(lastObject))]
228 #[unsafe(method_family = none)]
229 pub fn lastObject(&self) -> Option<Retained<ObjectType>>;
230
231 #[cfg(feature = "NSEnumerator")]
232 #[unsafe(method(objectEnumerator))]
233 #[unsafe(method_family = none)]
234 pub unsafe fn objectEnumerator(&self) -> Retained<NSEnumerator<ObjectType>>;
235
236 #[cfg(feature = "NSEnumerator")]
237 #[unsafe(method(reverseObjectEnumerator))]
238 #[unsafe(method_family = none)]
239 pub unsafe fn reverseObjectEnumerator(&self) -> Retained<NSEnumerator<ObjectType>>;
240
241 #[cfg(feature = "NSData")]
242 #[unsafe(method(sortedArrayHint))]
243 #[unsafe(method_family = none)]
244 pub unsafe fn sortedArrayHint(&self) -> Retained<NSData>;
245
246 #[unsafe(method(sortedArrayUsingFunction:context:))]
247 #[unsafe(method_family = none)]
248 pub unsafe fn sortedArrayUsingFunction_context(
249 &self,
250 comparator: unsafe extern "C-unwind" fn(
251 NonNull<ObjectType>,
252 NonNull<ObjectType>,
253 *mut c_void,
254 ) -> NSInteger,
255 context: *mut c_void,
256 ) -> Retained<NSArray<ObjectType>>;
257
258 #[cfg(feature = "NSData")]
259 #[unsafe(method(sortedArrayUsingFunction:context:hint:))]
260 #[unsafe(method_family = none)]
261 pub unsafe fn sortedArrayUsingFunction_context_hint(
262 &self,
263 comparator: unsafe extern "C-unwind" fn(
264 NonNull<ObjectType>,
265 NonNull<ObjectType>,
266 *mut c_void,
267 ) -> NSInteger,
268 context: *mut c_void,
269 hint: Option<&NSData>,
270 ) -> Retained<NSArray<ObjectType>>;
271
272 #[unsafe(method(sortedArrayUsingSelector:))]
273 #[unsafe(method_family = none)]
274 pub unsafe fn sortedArrayUsingSelector(
275 &self,
276 comparator: Sel,
277 ) -> Retained<NSArray<ObjectType>>;
278
279 #[cfg(feature = "NSRange")]
280 #[unsafe(method(subarrayWithRange:))]
281 #[unsafe(method_family = none)]
282 pub unsafe fn subarrayWithRange(&self, range: NSRange) -> Retained<NSArray<ObjectType>>;
283
284 #[cfg(all(feature = "NSError", feature = "NSURL"))]
285 #[unsafe(method(writeToURL:error:_))]
286 #[unsafe(method_family = none)]
287 pub unsafe fn writeToURL_error(&self, url: &NSURL) -> Result<(), Retained<NSError>>;
288
289 #[unsafe(method(makeObjectsPerformSelector:))]
290 #[unsafe(method_family = none)]
291 pub unsafe fn makeObjectsPerformSelector(&self, a_selector: Sel);
292
293 #[unsafe(method(makeObjectsPerformSelector:withObject:))]
294 #[unsafe(method_family = none)]
295 pub unsafe fn makeObjectsPerformSelector_withObject(
296 &self,
297 a_selector: Sel,
298 argument: Option<&AnyObject>,
299 );
300
301 #[cfg(feature = "NSIndexSet")]
302 #[unsafe(method(objectsAtIndexes:))]
303 #[unsafe(method_family = none)]
304 pub unsafe fn objectsAtIndexes(
305 &self,
306 indexes: &NSIndexSet,
307 ) -> Retained<NSArray<ObjectType>>;
308
309 #[unsafe(method(objectAtIndexedSubscript:))]
310 #[unsafe(method_family = none)]
311 pub unsafe fn objectAtIndexedSubscript(&self, idx: NSUInteger) -> Retained<ObjectType>;
312
313 #[cfg(feature = "block2")]
314 #[unsafe(method(enumerateObjectsUsingBlock:))]
315 #[unsafe(method_family = none)]
316 pub unsafe fn enumerateObjectsUsingBlock(
317 &self,
318 block: &block2::DynBlock<dyn Fn(NonNull<ObjectType>, NSUInteger, NonNull<Bool>) + '_>,
319 );
320
321 #[cfg(all(feature = "NSObjCRuntime", feature = "block2"))]
322 #[unsafe(method(enumerateObjectsWithOptions:usingBlock:))]
323 #[unsafe(method_family = none)]
324 pub unsafe fn enumerateObjectsWithOptions_usingBlock(
325 &self,
326 opts: NSEnumerationOptions,
327 block: &block2::DynBlock<dyn Fn(NonNull<ObjectType>, NSUInteger, NonNull<Bool>) + '_>,
328 );
329
330 #[cfg(all(feature = "NSIndexSet", feature = "NSObjCRuntime", feature = "block2"))]
331 #[unsafe(method(enumerateObjectsAtIndexes:options:usingBlock:))]
332 #[unsafe(method_family = none)]
333 pub unsafe fn enumerateObjectsAtIndexes_options_usingBlock(
334 &self,
335 s: &NSIndexSet,
336 opts: NSEnumerationOptions,
337 block: &block2::DynBlock<dyn Fn(NonNull<ObjectType>, NSUInteger, NonNull<Bool>) + '_>,
338 );
339
340 #[cfg(feature = "block2")]
341 #[unsafe(method(indexOfObjectPassingTest:))]
342 #[unsafe(method_family = none)]
343 pub unsafe fn indexOfObjectPassingTest(
344 &self,
345 predicate: &block2::DynBlock<
346 dyn Fn(NonNull<ObjectType>, NSUInteger, NonNull<Bool>) -> Bool + '_,
347 >,
348 ) -> NSUInteger;
349
350 #[cfg(all(feature = "NSObjCRuntime", feature = "block2"))]
351 #[unsafe(method(indexOfObjectWithOptions:passingTest:))]
352 #[unsafe(method_family = none)]
353 pub unsafe fn indexOfObjectWithOptions_passingTest(
354 &self,
355 opts: NSEnumerationOptions,
356 predicate: &block2::DynBlock<
357 dyn Fn(NonNull<ObjectType>, NSUInteger, NonNull<Bool>) -> Bool + '_,
358 >,
359 ) -> NSUInteger;
360
361 #[cfg(all(feature = "NSIndexSet", feature = "NSObjCRuntime", feature = "block2"))]
362 #[unsafe(method(indexOfObjectAtIndexes:options:passingTest:))]
363 #[unsafe(method_family = none)]
364 pub unsafe fn indexOfObjectAtIndexes_options_passingTest(
365 &self,
366 s: &NSIndexSet,
367 opts: NSEnumerationOptions,
368 predicate: &block2::DynBlock<
369 dyn Fn(NonNull<ObjectType>, NSUInteger, NonNull<Bool>) -> Bool + '_,
370 >,
371 ) -> NSUInteger;
372
373 #[cfg(all(feature = "NSIndexSet", feature = "block2"))]
374 #[unsafe(method(indexesOfObjectsPassingTest:))]
375 #[unsafe(method_family = none)]
376 pub unsafe fn indexesOfObjectsPassingTest(
377 &self,
378 predicate: &block2::DynBlock<
379 dyn Fn(NonNull<ObjectType>, NSUInteger, NonNull<Bool>) -> Bool + '_,
380 >,
381 ) -> Retained<NSIndexSet>;
382
383 #[cfg(all(feature = "NSIndexSet", feature = "NSObjCRuntime", feature = "block2"))]
384 #[unsafe(method(indexesOfObjectsWithOptions:passingTest:))]
385 #[unsafe(method_family = none)]
386 pub unsafe fn indexesOfObjectsWithOptions_passingTest(
387 &self,
388 opts: NSEnumerationOptions,
389 predicate: &block2::DynBlock<
390 dyn Fn(NonNull<ObjectType>, NSUInteger, NonNull<Bool>) -> Bool + '_,
391 >,
392 ) -> Retained<NSIndexSet>;
393
394 #[cfg(all(feature = "NSIndexSet", feature = "NSObjCRuntime", feature = "block2"))]
395 #[unsafe(method(indexesOfObjectsAtIndexes:options:passingTest:))]
396 #[unsafe(method_family = none)]
397 pub unsafe fn indexesOfObjectsAtIndexes_options_passingTest(
398 &self,
399 s: &NSIndexSet,
400 opts: NSEnumerationOptions,
401 predicate: &block2::DynBlock<
402 dyn Fn(NonNull<ObjectType>, NSUInteger, NonNull<Bool>) -> Bool + '_,
403 >,
404 ) -> Retained<NSIndexSet>;
405
406 #[cfg(all(feature = "NSObjCRuntime", feature = "block2"))]
407 #[unsafe(method(sortedArrayUsingComparator:))]
408 #[unsafe(method_family = none)]
409 pub unsafe fn sortedArrayUsingComparator(
410 &self,
411 cmptr: NSComparator,
412 ) -> Retained<NSArray<ObjectType>>;
413
414 #[cfg(all(feature = "NSObjCRuntime", feature = "block2"))]
415 #[unsafe(method(sortedArrayWithOptions:usingComparator:))]
416 #[unsafe(method_family = none)]
417 pub unsafe fn sortedArrayWithOptions_usingComparator(
418 &self,
419 opts: NSSortOptions,
420 cmptr: NSComparator,
421 ) -> Retained<NSArray<ObjectType>>;
422
423 #[cfg(all(feature = "NSObjCRuntime", feature = "NSRange", feature = "block2"))]
424 #[unsafe(method(indexOfObject:inSortedRange:options:usingComparator:))]
425 #[unsafe(method_family = none)]
426 pub unsafe fn indexOfObject_inSortedRange_options_usingComparator(
427 &self,
428 obj: &ObjectType,
429 r: NSRange,
430 opts: NSBinarySearchingOptions,
431 cmp: NSComparator,
432 ) -> NSUInteger;
433 );
434}
435
436impl<ObjectType: Message> NSArray<ObjectType> {
438 extern_methods!(
439 #[unsafe(method(array))]
440 #[unsafe(method_family = none)]
441 pub unsafe fn array() -> Retained<Self>;
442
443 #[unsafe(method(arrayWithObject:))]
444 #[unsafe(method_family = none)]
445 pub unsafe fn arrayWithObject(an_object: &ObjectType) -> Retained<Self>;
446
447 #[unsafe(method(arrayWithObjects:count:))]
448 #[unsafe(method_family = none)]
449 pub unsafe fn arrayWithObjects_count(
450 objects: NonNull<NonNull<ObjectType>>,
451 cnt: NSUInteger,
452 ) -> Retained<Self>;
453
454 #[unsafe(method(arrayWithArray:))]
455 #[unsafe(method_family = none)]
456 pub unsafe fn arrayWithArray(array: &NSArray<ObjectType>) -> Retained<Self>;
457
458 #[unsafe(method(initWithArray:))]
459 #[unsafe(method_family = init)]
460 pub unsafe fn initWithArray(
461 this: Allocated<Self>,
462 array: &NSArray<ObjectType>,
463 ) -> Retained<Self>;
464
465 #[unsafe(method(initWithArray:copyItems:))]
466 #[unsafe(method_family = init)]
467 pub unsafe fn initWithArray_copyItems(
468 this: Allocated<Self>,
469 array: &NSArray<ObjectType>,
470 flag: bool,
471 ) -> Retained<Self>;
472
473 #[cfg(all(feature = "NSError", feature = "NSURL"))]
474 #[unsafe(method(initWithContentsOfURL:error:_))]
475 #[unsafe(method_family = init)]
476 pub unsafe fn initWithContentsOfURL_error(
477 this: Allocated<Self>,
478 url: &NSURL,
479 ) -> Result<Retained<NSArray<ObjectType>>, Retained<NSError>>;
480
481 #[cfg(all(feature = "NSError", feature = "NSURL"))]
482 #[unsafe(method(arrayWithContentsOfURL:error:_))]
483 #[unsafe(method_family = none)]
484 pub unsafe fn arrayWithContentsOfURL_error(
485 url: &NSURL,
486 ) -> Result<Retained<NSArray<ObjectType>>, Retained<NSError>>;
487 );
488}
489
490impl<ObjectType: Message> NSMutableArray<ObjectType> {
494 extern_methods!(
495 #[unsafe(method(array))]
496 #[unsafe(method_family = none)]
497 pub unsafe fn array() -> Retained<Self>;
498
499 #[unsafe(method(arrayWithObject:))]
500 #[unsafe(method_family = none)]
501 pub unsafe fn arrayWithObject(an_object: &ObjectType) -> Retained<Self>;
502
503 #[unsafe(method(arrayWithObjects:count:))]
504 #[unsafe(method_family = none)]
505 pub unsafe fn arrayWithObjects_count(
506 objects: NonNull<NonNull<ObjectType>>,
507 cnt: NSUInteger,
508 ) -> Retained<Self>;
509
510 #[unsafe(method(arrayWithArray:))]
511 #[unsafe(method_family = none)]
512 pub unsafe fn arrayWithArray(array: &NSArray<ObjectType>) -> Retained<Self>;
513
514 #[unsafe(method(initWithArray:))]
515 #[unsafe(method_family = init)]
516 pub unsafe fn initWithArray(
517 this: Allocated<Self>,
518 array: &NSArray<ObjectType>,
519 ) -> Retained<Self>;
520
521 #[unsafe(method(initWithArray:copyItems:))]
522 #[unsafe(method_family = init)]
523 pub unsafe fn initWithArray_copyItems(
524 this: Allocated<Self>,
525 array: &NSArray<ObjectType>,
526 flag: bool,
527 ) -> Retained<Self>;
528 );
529}
530
531impl<ObjectType: Message> NSArray<ObjectType> {
533 extern_methods!(
534 #[cfg(all(feature = "NSOrderedCollectionDifference", feature = "block2"))]
535 #[unsafe(method(differenceFromArray:withOptions:usingEquivalenceTest:))]
536 #[unsafe(method_family = none)]
537 pub unsafe fn differenceFromArray_withOptions_usingEquivalenceTest(
538 &self,
539 other: &NSArray<ObjectType>,
540 options: NSOrderedCollectionDifferenceCalculationOptions,
541 block: &block2::DynBlock<dyn Fn(NonNull<ObjectType>, NonNull<ObjectType>) -> Bool + '_>,
542 ) -> Retained<NSOrderedCollectionDifference<ObjectType>>;
543
544 #[cfg(feature = "NSOrderedCollectionDifference")]
545 #[unsafe(method(differenceFromArray:withOptions:))]
546 #[unsafe(method_family = none)]
547 pub unsafe fn differenceFromArray_withOptions(
548 &self,
549 other: &NSArray<ObjectType>,
550 options: NSOrderedCollectionDifferenceCalculationOptions,
551 ) -> Retained<NSOrderedCollectionDifference<ObjectType>>;
552
553 #[cfg(feature = "NSOrderedCollectionDifference")]
554 #[unsafe(method(differenceFromArray:))]
555 #[unsafe(method_family = none)]
556 pub unsafe fn differenceFromArray(
557 &self,
558 other: &NSArray<ObjectType>,
559 ) -> Retained<NSOrderedCollectionDifference<ObjectType>>;
560
561 #[cfg(feature = "NSOrderedCollectionDifference")]
562 #[unsafe(method(arrayByApplyingDifference:))]
563 #[unsafe(method_family = none)]
564 pub unsafe fn arrayByApplyingDifference(
565 &self,
566 difference: &NSOrderedCollectionDifference<ObjectType>,
567 ) -> Option<Retained<NSArray<ObjectType>>>;
568 );
569}
570
571impl<ObjectType: Message> NSArray<ObjectType> {
573 extern_methods!(
574 #[deprecated = "Use -getObjects:range: instead"]
575 #[unsafe(method(getObjects:))]
576 #[unsafe(method_family = none)]
577 pub unsafe fn getObjects(&self, objects: NonNull<NonNull<ObjectType>>);
578
579 #[cfg(feature = "NSString")]
580 #[deprecated]
581 #[unsafe(method(arrayWithContentsOfFile:))]
582 #[unsafe(method_family = none)]
583 pub unsafe fn arrayWithContentsOfFile(
584 path: &NSString,
585 ) -> Option<Retained<NSArray<ObjectType>>>;
586
587 #[cfg(feature = "NSURL")]
588 #[deprecated]
589 #[unsafe(method(arrayWithContentsOfURL:))]
590 #[unsafe(method_family = none)]
591 pub unsafe fn arrayWithContentsOfURL(url: &NSURL) -> Option<Retained<NSArray<ObjectType>>>;
592
593 #[cfg(feature = "NSString")]
594 #[deprecated]
595 #[unsafe(method(initWithContentsOfFile:))]
596 #[unsafe(method_family = init)]
597 pub unsafe fn initWithContentsOfFile(
598 this: Allocated<Self>,
599 path: &NSString,
600 ) -> Option<Retained<NSArray<ObjectType>>>;
601
602 #[cfg(feature = "NSURL")]
603 #[deprecated]
604 #[unsafe(method(initWithContentsOfURL:))]
605 #[unsafe(method_family = init)]
606 pub unsafe fn initWithContentsOfURL(
607 this: Allocated<Self>,
608 url: &NSURL,
609 ) -> Option<Retained<NSArray<ObjectType>>>;
610
611 #[cfg(feature = "NSString")]
612 #[deprecated]
613 #[unsafe(method(writeToFile:atomically:))]
614 #[unsafe(method_family = none)]
615 pub unsafe fn writeToFile_atomically(
616 &self,
617 path: &NSString,
618 use_auxiliary_file: bool,
619 ) -> bool;
620
621 #[cfg(feature = "NSURL")]
622 #[deprecated]
623 #[unsafe(method(writeToURL:atomically:))]
624 #[unsafe(method_family = none)]
625 pub unsafe fn writeToURL_atomically(&self, url: &NSURL, atomically: bool) -> bool;
626 );
627}
628
629extern_class!(
630 #[unsafe(super(NSArray<ObjectType>, NSObject))]
634 #[derive(PartialEq, Eq, Hash)]
635 pub struct NSMutableArray<ObjectType: ?Sized = AnyObject>;
636);
637
638#[cfg(feature = "NSObject")]
639extern_conformance!(
640 unsafe impl<ObjectType: ?Sized + NSCoding> NSCoding for NSMutableArray<ObjectType> {}
641);
642
643#[cfg(feature = "NSObject")]
644extern_conformance!(
645 unsafe impl<ObjectType: ?Sized> NSCopying for NSMutableArray<ObjectType> {}
646);
647
648#[cfg(feature = "NSObject")]
649unsafe impl<ObjectType: ?Sized + Message> CopyingHelper for NSMutableArray<ObjectType> {
650 type Result = NSArray<ObjectType>;
651}
652
653#[cfg(feature = "NSEnumerator")]
654extern_conformance!(
655 unsafe impl<ObjectType: ?Sized> NSFastEnumeration for NSMutableArray<ObjectType> {}
656);
657
658#[cfg(feature = "NSObject")]
659extern_conformance!(
660 unsafe impl<ObjectType: ?Sized> NSMutableCopying for NSMutableArray<ObjectType> {}
661);
662
663#[cfg(feature = "NSObject")]
664unsafe impl<ObjectType: ?Sized + Message> MutableCopyingHelper for NSMutableArray<ObjectType> {
665 type Result = Self;
666}
667
668extern_conformance!(
669 unsafe impl<ObjectType: ?Sized> NSObjectProtocol for NSMutableArray<ObjectType> {}
670);
671
672#[cfg(feature = "NSObject")]
673extern_conformance!(
674 unsafe impl<ObjectType: ?Sized + NSSecureCoding> NSSecureCoding for NSMutableArray<ObjectType> {}
675);
676
677impl<ObjectType: Message> NSMutableArray<ObjectType> {
678 extern_methods!(
679 #[unsafe(method(addObject:))]
680 #[unsafe(method_family = none)]
681 pub fn addObject(&self, an_object: &ObjectType);
682
683 #[unsafe(method(insertObject:atIndex:))]
684 #[unsafe(method_family = none)]
685 pub fn insertObject_atIndex(&self, an_object: &ObjectType, index: NSUInteger);
686
687 #[unsafe(method(removeLastObject))]
688 #[unsafe(method_family = none)]
689 pub fn removeLastObject(&self);
690
691 #[unsafe(method(removeObjectAtIndex:))]
692 #[unsafe(method_family = none)]
693 pub fn removeObjectAtIndex(&self, index: NSUInteger);
694
695 #[unsafe(method(replaceObjectAtIndex:withObject:))]
696 #[unsafe(method_family = none)]
697 pub fn replaceObjectAtIndex_withObject(&self, index: NSUInteger, an_object: &ObjectType);
698
699 #[unsafe(method(init))]
700 #[unsafe(method_family = init)]
701 pub fn init(this: Allocated<Self>) -> Retained<Self>;
702
703 #[unsafe(method(initWithCapacity:))]
704 #[unsafe(method_family = init)]
705 pub fn initWithCapacity(this: Allocated<Self>, num_items: NSUInteger) -> Retained<Self>;
706
707 #[cfg(feature = "NSCoder")]
708 #[unsafe(method(initWithCoder:))]
709 #[unsafe(method_family = init)]
710 pub unsafe fn initWithCoder(
711 this: Allocated<Self>,
712 coder: &NSCoder,
713 ) -> Option<Retained<Self>>;
714 );
715}
716
717impl<ObjectType: Message> NSMutableArray<ObjectType> {
719 extern_methods!(
720 #[unsafe(method(initWithObjects:count:))]
721 #[unsafe(method_family = init)]
722 pub unsafe fn initWithObjects_count(
723 this: Allocated<Self>,
724 objects: *mut NonNull<ObjectType>,
725 cnt: NSUInteger,
726 ) -> Retained<Self>;
727 );
728}
729
730impl<ObjectType: Message> NSMutableArray<ObjectType> {
732 extern_methods!(
733 #[unsafe(method(new))]
734 #[unsafe(method_family = new)]
735 pub fn new() -> Retained<Self>;
736 );
737}
738
739impl<ObjectType: Message> DefaultRetained for NSMutableArray<ObjectType> {
740 #[inline]
741 fn default_retained() -> Retained<Self> {
742 Self::new()
743 }
744}
745
746impl<ObjectType: Message> NSMutableArray<ObjectType> {
748 extern_methods!(
749 #[unsafe(method(addObjectsFromArray:))]
750 #[unsafe(method_family = none)]
751 pub unsafe fn addObjectsFromArray(&self, other_array: &NSArray<ObjectType>);
752
753 #[unsafe(method(exchangeObjectAtIndex:withObjectAtIndex:))]
754 #[unsafe(method_family = none)]
755 pub unsafe fn exchangeObjectAtIndex_withObjectAtIndex(
756 &self,
757 idx1: NSUInteger,
758 idx2: NSUInteger,
759 );
760
761 #[unsafe(method(removeAllObjects))]
762 #[unsafe(method_family = none)]
763 pub fn removeAllObjects(&self);
764
765 #[cfg(feature = "NSRange")]
766 #[unsafe(method(removeObject:inRange:))]
767 #[unsafe(method_family = none)]
768 pub unsafe fn removeObject_inRange(&self, an_object: &ObjectType, range: NSRange);
769
770 #[unsafe(method(removeObject:))]
771 #[unsafe(method_family = none)]
772 pub fn removeObject(&self, an_object: &ObjectType);
773
774 #[cfg(feature = "NSRange")]
775 #[unsafe(method(removeObjectIdenticalTo:inRange:))]
776 #[unsafe(method_family = none)]
777 pub unsafe fn removeObjectIdenticalTo_inRange(
778 &self,
779 an_object: &ObjectType,
780 range: NSRange,
781 );
782
783 #[unsafe(method(removeObjectIdenticalTo:))]
784 #[unsafe(method_family = none)]
785 pub unsafe fn removeObjectIdenticalTo(&self, an_object: &ObjectType);
786
787 #[deprecated = "Not supported"]
788 #[unsafe(method(removeObjectsFromIndices:numIndices:))]
789 #[unsafe(method_family = none)]
790 pub unsafe fn removeObjectsFromIndices_numIndices(
791 &self,
792 indices: NonNull<NSUInteger>,
793 cnt: NSUInteger,
794 );
795
796 #[unsafe(method(removeObjectsInArray:))]
797 #[unsafe(method_family = none)]
798 pub unsafe fn removeObjectsInArray(&self, other_array: &NSArray<ObjectType>);
799
800 #[cfg(feature = "NSRange")]
801 #[unsafe(method(removeObjectsInRange:))]
802 #[unsafe(method_family = none)]
803 pub unsafe fn removeObjectsInRange(&self, range: NSRange);
804
805 #[cfg(feature = "NSRange")]
806 #[unsafe(method(replaceObjectsInRange:withObjectsFromArray:range:))]
807 #[unsafe(method_family = none)]
808 pub unsafe fn replaceObjectsInRange_withObjectsFromArray_range(
809 &self,
810 range: NSRange,
811 other_array: &NSArray<ObjectType>,
812 other_range: NSRange,
813 );
814
815 #[cfg(feature = "NSRange")]
816 #[unsafe(method(replaceObjectsInRange:withObjectsFromArray:))]
817 #[unsafe(method_family = none)]
818 pub unsafe fn replaceObjectsInRange_withObjectsFromArray(
819 &self,
820 range: NSRange,
821 other_array: &NSArray<ObjectType>,
822 );
823
824 #[unsafe(method(setArray:))]
825 #[unsafe(method_family = none)]
826 pub unsafe fn setArray(&self, other_array: &NSArray<ObjectType>);
827
828 #[unsafe(method(sortUsingFunction:context:))]
829 #[unsafe(method_family = none)]
830 pub unsafe fn sortUsingFunction_context(
831 &self,
832 compare: unsafe extern "C-unwind" fn(
833 NonNull<ObjectType>,
834 NonNull<ObjectType>,
835 *mut c_void,
836 ) -> NSInteger,
837 context: *mut c_void,
838 );
839
840 #[unsafe(method(sortUsingSelector:))]
841 #[unsafe(method_family = none)]
842 pub unsafe fn sortUsingSelector(&self, comparator: Sel);
843
844 #[cfg(feature = "NSIndexSet")]
845 #[unsafe(method(insertObjects:atIndexes:))]
846 #[unsafe(method_family = none)]
847 pub unsafe fn insertObjects_atIndexes(
848 &self,
849 objects: &NSArray<ObjectType>,
850 indexes: &NSIndexSet,
851 );
852
853 #[cfg(feature = "NSIndexSet")]
854 #[unsafe(method(removeObjectsAtIndexes:))]
855 #[unsafe(method_family = none)]
856 pub unsafe fn removeObjectsAtIndexes(&self, indexes: &NSIndexSet);
857
858 #[cfg(feature = "NSIndexSet")]
859 #[unsafe(method(replaceObjectsAtIndexes:withObjects:))]
860 #[unsafe(method_family = none)]
861 pub unsafe fn replaceObjectsAtIndexes_withObjects(
862 &self,
863 indexes: &NSIndexSet,
864 objects: &NSArray<ObjectType>,
865 );
866
867 #[unsafe(method(setObject:atIndexedSubscript:))]
868 #[unsafe(method_family = none)]
869 pub unsafe fn setObject_atIndexedSubscript(&self, obj: &ObjectType, idx: NSUInteger);
870
871 #[cfg(all(feature = "NSObjCRuntime", feature = "block2"))]
872 #[unsafe(method(sortUsingComparator:))]
873 #[unsafe(method_family = none)]
874 pub unsafe fn sortUsingComparator(&self, cmptr: NSComparator);
875
876 #[cfg(all(feature = "NSObjCRuntime", feature = "block2"))]
877 #[unsafe(method(sortWithOptions:usingComparator:))]
878 #[unsafe(method_family = none)]
879 pub unsafe fn sortWithOptions_usingComparator(
880 &self,
881 opts: NSSortOptions,
882 cmptr: NSComparator,
883 );
884 );
885}
886
887impl<ObjectType: Message> NSMutableArray<ObjectType> {
889 extern_methods!(
890 #[unsafe(method(arrayWithCapacity:))]
891 #[unsafe(method_family = none)]
892 pub unsafe fn arrayWithCapacity(num_items: NSUInteger) -> Retained<Self>;
893
894 #[cfg(feature = "NSString")]
895 #[unsafe(method(arrayWithContentsOfFile:))]
896 #[unsafe(method_family = none)]
897 pub unsafe fn arrayWithContentsOfFile(
898 path: &NSString,
899 ) -> Option<Retained<NSMutableArray<ObjectType>>>;
900
901 #[cfg(feature = "NSURL")]
902 #[unsafe(method(arrayWithContentsOfURL:))]
903 #[unsafe(method_family = none)]
904 pub unsafe fn arrayWithContentsOfURL(
905 url: &NSURL,
906 ) -> Option<Retained<NSMutableArray<ObjectType>>>;
907
908 #[cfg(feature = "NSString")]
909 #[unsafe(method(initWithContentsOfFile:))]
910 #[unsafe(method_family = init)]
911 pub unsafe fn initWithContentsOfFile(
912 this: Allocated<Self>,
913 path: &NSString,
914 ) -> Option<Retained<NSMutableArray<ObjectType>>>;
915
916 #[cfg(feature = "NSURL")]
917 #[unsafe(method(initWithContentsOfURL:))]
918 #[unsafe(method_family = init)]
919 pub unsafe fn initWithContentsOfURL(
920 this: Allocated<Self>,
921 url: &NSURL,
922 ) -> Option<Retained<NSMutableArray<ObjectType>>>;
923 );
924}
925
926impl<ObjectType: Message> NSMutableArray<ObjectType> {
928 extern_methods!(
929 #[cfg(feature = "NSOrderedCollectionDifference")]
930 #[unsafe(method(applyDifference:))]
931 #[unsafe(method_family = none)]
932 pub unsafe fn applyDifference(
933 &self,
934 difference: &NSOrderedCollectionDifference<ObjectType>,
935 );
936 );
937}