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