//! This file has been automatically generated by `objc2`'s `header-translator`. //! DO NOT EDIT use core::ffi::*; use core::ptr::NonNull; use objc2::__framework_prelude::*; #[cfg(feature = "objc2-core-foundation")] use objc2_core_foundation::*; use crate::*; extern_class!( /// ************** Immutable Dictionary *************** /// /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsdictionary?language=objc) #[unsafe(super(NSObject))] #[derive(PartialEq, Eq, Hash)] pub struct NSDictionary; ); #[cfg(feature = "objc2-core-foundation")] impl AsRef> for CFDictionary { #[inline] fn as_ref(&self) -> &NSDictionary { unsafe { &*((self as *const Self).cast()) } } } #[cfg(feature = "objc2-core-foundation")] impl AsRef> for NSDictionary { #[inline] fn as_ref(&self) -> &CFDictionary { unsafe { &*((self as *const Self).cast()) } } } impl NSDictionary { /// Unchecked conversion of the generic parameters. /// /// # Safety /// /// The generics must be valid to reinterpret as the given types. #[inline] pub unsafe fn cast_unchecked( &self, ) -> &NSDictionary { unsafe { &*((self as *const Self).cast()) } } } #[cfg(feature = "NSObject")] extern_conformance!( unsafe impl NSCoding for NSDictionary { } ); #[cfg(feature = "NSObject")] extern_conformance!( unsafe impl NSCopying for NSDictionary {} ); #[cfg(feature = "NSObject")] unsafe impl CopyingHelper for NSDictionary { type Result = Self; } #[cfg(feature = "NSEnumerator")] extern_conformance!( unsafe impl NSFastEnumeration for NSDictionary { } ); #[cfg(feature = "NSObject")] extern_conformance!( unsafe impl NSMutableCopying for NSDictionary { } ); #[cfg(feature = "NSObject")] unsafe impl MutableCopyingHelper for NSDictionary { type Result = NSMutableDictionary; } extern_conformance!( unsafe impl NSObjectProtocol for NSDictionary { } ); #[cfg(feature = "NSObject")] extern_conformance!( unsafe impl NSSecureCoding for NSDictionary { } ); impl NSDictionary { extern_methods!( #[unsafe(method(count))] #[unsafe(method_family = none)] pub fn count(&self) -> NSUInteger; #[unsafe(method(objectForKey:))] #[unsafe(method_family = none)] pub fn objectForKey(&self, a_key: &KeyType) -> Option>; #[cfg(feature = "NSEnumerator")] /// # Safety /// /// The returned enumerator's underlying collection should not be mutated while in use. #[unsafe(method(keyEnumerator))] #[unsafe(method_family = none)] pub unsafe fn keyEnumerator(&self) -> Retained>; #[unsafe(method(init))] #[unsafe(method_family = init)] pub fn init(this: Allocated) -> Retained; #[cfg(feature = "NSObject")] /// # Safety /// /// - `objects` must be a valid pointer or null. /// - `keys` must be a valid pointer or null. #[unsafe(method(initWithObjects:forKeys:count:))] #[unsafe(method_family = init)] pub unsafe fn initWithObjects_forKeys_count( this: Allocated, objects: *mut NonNull, keys: *mut NonNull>, cnt: NSUInteger, ) -> Retained; #[cfg(feature = "NSCoder")] /// # Safety /// /// `coder` possibly has further requirements. #[unsafe(method(initWithCoder:))] #[unsafe(method_family = init)] pub unsafe fn initWithCoder( this: Allocated, coder: &NSCoder, ) -> Option>; ); } /// Methods declared on superclass `NSObject`. impl NSDictionary { extern_methods!( #[unsafe(method(new))] #[unsafe(method_family = new)] pub fn new() -> Retained; ); } impl DefaultRetained for NSDictionary { #[inline] fn default_retained() -> Retained { Self::new() } } /// NSExtendedDictionary. impl NSDictionary { extern_methods!( #[cfg(feature = "NSArray")] #[unsafe(method(allKeys))] #[unsafe(method_family = none)] pub fn allKeys(&self) -> Retained>; #[cfg(feature = "NSArray")] #[unsafe(method(allKeysForObject:))] #[unsafe(method_family = none)] pub fn allKeysForObject(&self, an_object: &ObjectType) -> Retained>; #[cfg(feature = "NSArray")] #[unsafe(method(allValues))] #[unsafe(method_family = none)] pub fn allValues(&self) -> Retained>; #[cfg(feature = "NSString")] #[unsafe(method(description))] #[unsafe(method_family = none)] pub fn description(&self) -> Retained; #[cfg(feature = "NSString")] #[unsafe(method(descriptionInStringsFileFormat))] #[unsafe(method_family = none)] pub fn descriptionInStringsFileFormat(&self) -> Retained; #[cfg(feature = "NSString")] /// # Safety /// /// `locale` should be of the correct type. #[unsafe(method(descriptionWithLocale:))] #[unsafe(method_family = none)] pub unsafe fn descriptionWithLocale( &self, locale: Option<&AnyObject>, ) -> Retained; #[cfg(feature = "NSString")] /// # Safety /// /// `locale` should be of the correct type. #[unsafe(method(descriptionWithLocale:indent:))] #[unsafe(method_family = none)] pub unsafe fn descriptionWithLocale_indent( &self, locale: Option<&AnyObject>, level: NSUInteger, ) -> Retained; #[unsafe(method(isEqualToDictionary:))] #[unsafe(method_family = none)] pub fn isEqualToDictionary( &self, other_dictionary: &NSDictionary, ) -> bool; #[cfg(feature = "NSEnumerator")] /// # Safety /// /// The returned enumerator's underlying collection should not be mutated while in use. #[unsafe(method(objectEnumerator))] #[unsafe(method_family = none)] pub unsafe fn objectEnumerator(&self) -> Retained>; #[cfg(feature = "NSArray")] #[unsafe(method(objectsForKeys:notFoundMarker:))] #[unsafe(method_family = none)] pub fn objectsForKeys_notFoundMarker( &self, keys: &NSArray, marker: &ObjectType, ) -> Retained>; #[cfg(all(feature = "NSError", feature = "NSURL"))] #[unsafe(method(writeToURL:error:_))] #[unsafe(method_family = none)] pub unsafe fn writeToURL_error(&self, url: &NSURL) -> Result<(), Retained>; #[cfg(feature = "NSArray")] /// # Safety /// /// `comparator` must be a valid selector. #[unsafe(method(keysSortedByValueUsingSelector:))] #[unsafe(method_family = none)] pub unsafe fn keysSortedByValueUsingSelector( &self, comparator: Sel, ) -> Retained>; /// # Safety /// /// - `objects` must be a valid pointer or null. /// - `keys` must be a valid pointer or null. #[unsafe(method(getObjects:andKeys:count:))] #[unsafe(method_family = none)] pub unsafe fn getObjects_andKeys_count( &self, objects: *mut NonNull, keys: *mut NonNull, count: NSUInteger, ); #[unsafe(method(objectForKeyedSubscript:))] #[unsafe(method_family = none)] pub fn objectForKeyedSubscript(&self, key: &KeyType) -> Option>; #[cfg(feature = "block2")] #[unsafe(method(enumerateKeysAndObjectsUsingBlock:))] #[unsafe(method_family = none)] pub fn enumerateKeysAndObjectsUsingBlock( &self, block: &block2::DynBlock< dyn Fn(NonNull, NonNull, NonNull) + '_, >, ); #[cfg(all(feature = "NSObjCRuntime", feature = "block2"))] #[unsafe(method(enumerateKeysAndObjectsWithOptions:usingBlock:))] #[unsafe(method_family = none)] pub fn enumerateKeysAndObjectsWithOptions_usingBlock( &self, opts: NSEnumerationOptions, block: &block2::DynBlock< dyn Fn(NonNull, NonNull, NonNull) + '_, >, ); #[cfg(all(feature = "NSArray", feature = "NSObjCRuntime", feature = "block2"))] /// # Safety /// /// `cmptr` must be a valid pointer. #[unsafe(method(keysSortedByValueUsingComparator:))] #[unsafe(method_family = none)] pub unsafe fn keysSortedByValueUsingComparator( &self, cmptr: NSComparator, ) -> Retained>; #[cfg(all(feature = "NSArray", feature = "NSObjCRuntime", feature = "block2"))] /// # Safety /// /// `cmptr` must be a valid pointer. #[unsafe(method(keysSortedByValueWithOptions:usingComparator:))] #[unsafe(method_family = none)] pub unsafe fn keysSortedByValueWithOptions_usingComparator( &self, opts: NSSortOptions, cmptr: NSComparator, ) -> Retained>; #[cfg(all(feature = "NSSet", feature = "block2"))] #[unsafe(method(keysOfEntriesPassingTest:))] #[unsafe(method_family = none)] pub fn keysOfEntriesPassingTest( &self, predicate: &block2::DynBlock< dyn Fn(NonNull, NonNull, NonNull) -> Bool + '_, >, ) -> Retained>; #[cfg(all(feature = "NSObjCRuntime", feature = "NSSet", feature = "block2"))] #[unsafe(method(keysOfEntriesWithOptions:passingTest:))] #[unsafe(method_family = none)] pub fn keysOfEntriesWithOptions_passingTest( &self, opts: NSEnumerationOptions, predicate: &block2::DynBlock< dyn Fn(NonNull, NonNull, NonNull) -> Bool + '_, >, ) -> Retained>; ); } /// NSDeprecated. impl NSDictionary { extern_methods!( /// This method is unsafe because it could potentially cause buffer overruns. You should use -getObjects:andKeys:count: /// /// # Safety /// /// - `objects` must be a valid pointer or null. /// - `keys` must be a valid pointer or null. #[deprecated = "Use -getObjects:andKeys:count: instead"] #[unsafe(method(getObjects:andKeys:))] #[unsafe(method_family = none)] pub unsafe fn getObjects_andKeys( &self, objects: *mut NonNull, keys: *mut NonNull, ); #[cfg(feature = "NSString")] #[deprecated] #[unsafe(method(dictionaryWithContentsOfFile:))] #[unsafe(method_family = none)] pub unsafe fn dictionaryWithContentsOfFile( path: &NSString, ) -> Option>>; #[cfg(feature = "NSURL")] #[deprecated] #[unsafe(method(dictionaryWithContentsOfURL:))] #[unsafe(method_family = none)] pub unsafe fn dictionaryWithContentsOfURL( url: &NSURL, ) -> Option>>; #[cfg(feature = "NSString")] #[deprecated] #[unsafe(method(initWithContentsOfFile:))] #[unsafe(method_family = init)] pub unsafe fn initWithContentsOfFile( this: Allocated, path: &NSString, ) -> Option>>; #[cfg(feature = "NSURL")] #[deprecated] #[unsafe(method(initWithContentsOfURL:))] #[unsafe(method_family = init)] pub unsafe fn initWithContentsOfURL( this: Allocated, url: &NSURL, ) -> Option>>; #[cfg(feature = "NSString")] #[deprecated] #[unsafe(method(writeToFile:atomically:))] #[unsafe(method_family = none)] pub unsafe fn writeToFile_atomically( &self, path: &NSString, use_auxiliary_file: bool, ) -> bool; #[cfg(feature = "NSURL")] #[deprecated] #[unsafe(method(writeToURL:atomically:))] #[unsafe(method_family = none)] pub unsafe fn writeToURL_atomically(&self, url: &NSURL, atomically: bool) -> bool; ); } /// NSDictionaryCreation. impl NSDictionary { extern_methods!( #[unsafe(method(dictionary))] #[unsafe(method_family = none)] pub fn dictionary() -> Retained; #[cfg(feature = "NSObject")] /// # Safety /// /// `key` should be of the correct type. #[unsafe(method(dictionaryWithObject:forKey:))] #[unsafe(method_family = none)] pub unsafe fn dictionaryWithObject_forKey( object: &ObjectType, key: &ProtocolObject, ) -> Retained; #[cfg(feature = "NSObject")] /// # Safety /// /// - `objects` must be a valid pointer or null. /// - `keys` must be a valid pointer or null. #[unsafe(method(dictionaryWithObjects:forKeys:count:))] #[unsafe(method_family = none)] pub unsafe fn dictionaryWithObjects_forKeys_count( objects: *mut NonNull, keys: *mut NonNull>, cnt: NSUInteger, ) -> Retained; #[unsafe(method(dictionaryWithDictionary:))] #[unsafe(method_family = none)] pub fn dictionaryWithDictionary(dict: &NSDictionary) -> Retained; #[cfg(all(feature = "NSArray", feature = "NSObject"))] /// # Safety /// /// `keys` generic should be of the correct type. #[unsafe(method(dictionaryWithObjects:forKeys:))] #[unsafe(method_family = none)] pub unsafe fn dictionaryWithObjects_forKeys( objects: &NSArray, keys: &NSArray>, ) -> Retained; #[unsafe(method(initWithDictionary:))] #[unsafe(method_family = init)] pub fn initWithDictionary( this: Allocated, other_dictionary: &NSDictionary, ) -> Retained; #[unsafe(method(initWithDictionary:copyItems:))] #[unsafe(method_family = init)] pub unsafe fn initWithDictionary_copyItems( this: Allocated, other_dictionary: &NSDictionary, flag: bool, ) -> Retained; #[cfg(all(feature = "NSArray", feature = "NSObject"))] /// # Safety /// /// `keys` generic should be of the correct type. #[unsafe(method(initWithObjects:forKeys:))] #[unsafe(method_family = init)] pub unsafe fn initWithObjects_forKeys( this: Allocated, objects: &NSArray, keys: &NSArray>, ) -> Retained; ); } /// Methods declared on superclass `NSDictionary`. /// /// NSDictionaryCreation. impl NSMutableDictionary { extern_methods!( #[unsafe(method(dictionary))] #[unsafe(method_family = none)] pub fn dictionary() -> Retained; #[cfg(feature = "NSObject")] /// # Safety /// /// `key` should be of the correct type. #[unsafe(method(dictionaryWithObject:forKey:))] #[unsafe(method_family = none)] pub unsafe fn dictionaryWithObject_forKey( object: &ObjectType, key: &ProtocolObject, ) -> Retained; #[cfg(feature = "NSObject")] /// # Safety /// /// - `objects` must be a valid pointer or null. /// - `keys` must be a valid pointer or null. #[unsafe(method(dictionaryWithObjects:forKeys:count:))] #[unsafe(method_family = none)] pub unsafe fn dictionaryWithObjects_forKeys_count( objects: *mut NonNull, keys: *mut NonNull>, cnt: NSUInteger, ) -> Retained; #[unsafe(method(dictionaryWithDictionary:))] #[unsafe(method_family = none)] pub fn dictionaryWithDictionary(dict: &NSDictionary) -> Retained; #[cfg(all(feature = "NSArray", feature = "NSObject"))] /// # Safety /// /// `keys` generic should be of the correct type. #[unsafe(method(dictionaryWithObjects:forKeys:))] #[unsafe(method_family = none)] pub unsafe fn dictionaryWithObjects_forKeys( objects: &NSArray, keys: &NSArray>, ) -> Retained; #[unsafe(method(initWithDictionary:))] #[unsafe(method_family = init)] pub fn initWithDictionary( this: Allocated, other_dictionary: &NSDictionary, ) -> Retained; #[unsafe(method(initWithDictionary:copyItems:))] #[unsafe(method_family = init)] pub unsafe fn initWithDictionary_copyItems( this: Allocated, other_dictionary: &NSDictionary, flag: bool, ) -> Retained; #[cfg(all(feature = "NSArray", feature = "NSObject"))] /// # Safety /// /// `keys` generic should be of the correct type. #[unsafe(method(initWithObjects:forKeys:))] #[unsafe(method_family = init)] pub unsafe fn initWithObjects_forKeys( this: Allocated, objects: &NSArray, keys: &NSArray>, ) -> Retained; ); } extern_class!( /// ************** Mutable Dictionary *************** /// /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmutabledictionary?language=objc) #[unsafe(super(NSDictionary, NSObject))] #[derive(PartialEq, Eq, Hash)] pub struct NSMutableDictionary; ); #[cfg(feature = "objc2-core-foundation")] impl AsRef> for CFMutableDictionary { #[inline] fn as_ref(&self) -> &NSMutableDictionary { unsafe { &*((self as *const Self).cast()) } } } #[cfg(feature = "objc2-core-foundation")] impl AsRef> for NSMutableDictionary { #[inline] fn as_ref(&self) -> &CFMutableDictionary { unsafe { &*((self as *const Self).cast()) } } } impl NSMutableDictionary { /// Unchecked conversion of the generic parameters. /// /// # Safety /// /// The generics must be valid to reinterpret as the given types. #[inline] pub unsafe fn cast_unchecked( &self, ) -> &NSMutableDictionary { unsafe { &*((self as *const Self).cast()) } } } #[cfg(feature = "NSObject")] extern_conformance!( unsafe impl NSCoding for NSMutableDictionary { } ); #[cfg(feature = "NSObject")] extern_conformance!( unsafe impl NSCopying for NSMutableDictionary { } ); #[cfg(feature = "NSObject")] unsafe impl CopyingHelper for NSMutableDictionary { type Result = NSDictionary; } #[cfg(feature = "NSEnumerator")] extern_conformance!( unsafe impl NSFastEnumeration for NSMutableDictionary { } ); #[cfg(feature = "NSObject")] extern_conformance!( unsafe impl NSMutableCopying for NSMutableDictionary { } ); #[cfg(feature = "NSObject")] unsafe impl MutableCopyingHelper for NSMutableDictionary { type Result = Self; } extern_conformance!( unsafe impl NSObjectProtocol for NSMutableDictionary { } ); #[cfg(feature = "NSObject")] extern_conformance!( unsafe impl NSSecureCoding for NSMutableDictionary { } ); impl NSMutableDictionary { extern_methods!( #[unsafe(method(removeObjectForKey:))] #[unsafe(method_family = none)] pub fn removeObjectForKey(&self, a_key: &KeyType); #[cfg(feature = "NSObject")] /// # Safety /// /// `a_key` should be of the correct type. #[unsafe(method(setObject:forKey:))] #[unsafe(method_family = none)] pub unsafe fn setObject_forKey( &self, an_object: &ObjectType, a_key: &ProtocolObject, ); #[unsafe(method(init))] #[unsafe(method_family = init)] pub fn init(this: Allocated) -> Retained; #[unsafe(method(initWithCapacity:))] #[unsafe(method_family = init)] pub fn initWithCapacity(this: Allocated, num_items: NSUInteger) -> Retained; #[cfg(feature = "NSCoder")] /// # Safety /// /// `coder` possibly has further requirements. #[unsafe(method(initWithCoder:))] #[unsafe(method_family = init)] pub unsafe fn initWithCoder( this: Allocated, coder: &NSCoder, ) -> Option>; ); } /// Methods declared on superclass `NSDictionary`. impl NSMutableDictionary { extern_methods!( #[cfg(feature = "NSObject")] /// # Safety /// /// - `objects` must be a valid pointer or null. /// - `keys` must be a valid pointer or null. #[unsafe(method(initWithObjects:forKeys:count:))] #[unsafe(method_family = init)] pub unsafe fn initWithObjects_forKeys_count( this: Allocated, objects: *mut NonNull, keys: *mut NonNull>, cnt: NSUInteger, ) -> Retained; ); } /// Methods declared on superclass `NSObject`. impl NSMutableDictionary { extern_methods!( #[unsafe(method(new))] #[unsafe(method_family = new)] pub fn new() -> Retained; ); } impl DefaultRetained for NSMutableDictionary { #[inline] fn default_retained() -> Retained { Self::new() } } /// NSExtendedMutableDictionary. impl NSMutableDictionary { extern_methods!( #[unsafe(method(addEntriesFromDictionary:))] #[unsafe(method_family = none)] pub fn addEntriesFromDictionary( &self, other_dictionary: &NSDictionary, ); #[unsafe(method(removeAllObjects))] #[unsafe(method_family = none)] pub fn removeAllObjects(&self); #[cfg(feature = "NSArray")] #[unsafe(method(removeObjectsForKeys:))] #[unsafe(method_family = none)] pub fn removeObjectsForKeys(&self, key_array: &NSArray); #[unsafe(method(setDictionary:))] #[unsafe(method_family = none)] pub fn setDictionary(&self, other_dictionary: &NSDictionary); #[cfg(feature = "NSObject")] /// # Safety /// /// `key` should be of the correct type. #[unsafe(method(setObject:forKeyedSubscript:))] #[unsafe(method_family = none)] pub unsafe fn setObject_forKeyedSubscript( &self, obj: Option<&ObjectType>, key: &ProtocolObject, ); ); } /// NSMutableDictionaryCreation. impl NSMutableDictionary { extern_methods!( #[unsafe(method(dictionaryWithCapacity:))] #[unsafe(method_family = none)] pub fn dictionaryWithCapacity(num_items: NSUInteger) -> Retained; #[cfg(feature = "NSString")] #[unsafe(method(dictionaryWithContentsOfFile:))] #[unsafe(method_family = none)] pub unsafe fn dictionaryWithContentsOfFile( path: &NSString, ) -> Option>>; #[cfg(feature = "NSURL")] #[unsafe(method(dictionaryWithContentsOfURL:))] #[unsafe(method_family = none)] pub unsafe fn dictionaryWithContentsOfURL( url: &NSURL, ) -> Option>>; #[cfg(feature = "NSString")] #[unsafe(method(initWithContentsOfFile:))] #[unsafe(method_family = init)] pub unsafe fn initWithContentsOfFile( this: Allocated, path: &NSString, ) -> Option>>; #[cfg(feature = "NSURL")] #[unsafe(method(initWithContentsOfURL:))] #[unsafe(method_family = init)] pub unsafe fn initWithContentsOfURL( this: Allocated, url: &NSURL, ) -> Option>>; ); } /// NSSharedKeySetDictionary. impl NSDictionary { extern_methods!( #[cfg(all(feature = "NSArray", feature = "NSObject"))] /// # Safety /// /// `keys` generic should be of the correct type. #[unsafe(method(sharedKeySetForKeys:))] #[unsafe(method_family = none)] pub unsafe fn sharedKeySetForKeys( keys: &NSArray>, ) -> Retained; ); } /// NSSharedKeySetDictionary. impl NSMutableDictionary { extern_methods!( /// # Safety /// /// `keyset` should be of the correct type. #[unsafe(method(dictionaryWithSharedKeySet:))] #[unsafe(method_family = none)] pub unsafe fn dictionaryWithSharedKeySet( keyset: &AnyObject, ) -> Retained>; ); }