Struct objc2_foundation::NSSet
source · #[repr(C)]pub struct NSSet<ObjectType: ?Sized = AnyObject> { /* private fields */ }
NSSet
only.Implementations§
source§impl<ObjectType: Message> NSSet<ObjectType>
impl<ObjectType: Message> NSSet<ObjectType>
NSKeyValueCoding
pub unsafe fn valueForKey(&self, key: &NSString) -> Retained<AnyObject>
NSKeyValueCoding
and NSString
only.pub unsafe fn setValue_forKey(&self, value: Option<&AnyObject>, key: &NSString)
NSKeyValueCoding
and NSString
only.source§impl<ObjectType: Message> NSSet<ObjectType>
impl<ObjectType: Message> NSSet<ObjectType>
NSKeyValueObserverRegistration
pub unsafe fn addObserver_forKeyPath_options_context( &self, observer: &NSObject, key_path: &NSString, options: NSKeyValueObservingOptions, context: *mut c_void )
NSKeyValueObserving
and NSString
only.pub unsafe fn removeObserver_forKeyPath_context( &self, observer: &NSObject, key_path: &NSString, context: *mut c_void )
NSKeyValueObserving
and NSString
only.pub unsafe fn removeObserver_forKeyPath( &self, observer: &NSObject, key_path: &NSString )
NSKeyValueObserving
and NSString
only.source§impl<ObjectType: Message> NSSet<ObjectType>
impl<ObjectType: Message> NSSet<ObjectType>
NSPredicateSupport
pub unsafe fn filteredSetUsingPredicate( &self, predicate: &NSPredicate ) -> Retained<NSSet<ObjectType>>
NSPredicate
only.source§impl<ObjectType: Message> NSSet<ObjectType>
impl<ObjectType: Message> NSSet<ObjectType>
pub fn count(&self) -> NSUInteger
pub unsafe fn member(&self, object: &ObjectType) -> Option<Retained<ObjectType>>
pub unsafe fn objectEnumerator(&self) -> Retained<NSEnumerator<ObjectType>>
NSEnumerator
only.pub fn init(this: Allocated<Self>) -> Retained<Self>
pub unsafe fn initWithObjects_count( this: Allocated<Self>, objects: *mut NonNull<ObjectType>, cnt: NSUInteger ) -> Retained<Self>
pub unsafe fn initWithCoder( this: Allocated<Self>, coder: &NSCoder ) -> Option<Retained<Self>>
NSCoder
only.source§impl<ObjectType: Message> NSSet<ObjectType>
impl<ObjectType: Message> NSSet<ObjectType>
NSExtendedSet
pub unsafe fn allObjects(&self) -> Retained<NSArray<ObjectType>>
NSArray
only.pub unsafe fn anyObject(&self) -> Option<Retained<ObjectType>>
pub unsafe fn containsObject(&self, an_object: &ObjectType) -> bool
pub unsafe fn description(&self) -> Retained<NSString>
NSString
only.pub unsafe fn descriptionWithLocale( &self, locale: Option<&AnyObject> ) -> Retained<NSString>
NSString
only.pub unsafe fn intersectsSet(&self, other_set: &NSSet<ObjectType>) -> bool
pub unsafe fn isEqualToSet(&self, other_set: &NSSet<ObjectType>) -> bool
pub unsafe fn isSubsetOfSet(&self, other_set: &NSSet<ObjectType>) -> bool
pub unsafe fn makeObjectsPerformSelector(&self, a_selector: Sel)
pub unsafe fn makeObjectsPerformSelector_withObject( &self, a_selector: Sel, argument: Option<&AnyObject> )
pub unsafe fn setByAddingObject( &self, an_object: &ObjectType ) -> Retained<NSSet<ObjectType>>
pub unsafe fn setByAddingObjectsFromSet( &self, other: &NSSet<ObjectType> ) -> Retained<NSSet<ObjectType>>
pub unsafe fn setByAddingObjectsFromArray( &self, other: &NSArray<ObjectType> ) -> Retained<NSSet<ObjectType>>
NSArray
only.pub unsafe fn enumerateObjectsUsingBlock( &self, block: &Block<dyn Fn(NonNull<ObjectType>, NonNull<Bool>) + '_> )
block2
only.pub unsafe fn enumerateObjectsWithOptions_usingBlock( &self, opts: NSEnumerationOptions, block: &Block<dyn Fn(NonNull<ObjectType>, NonNull<Bool>) + '_> )
NSObjCRuntime
and block2
only.pub unsafe fn objectsPassingTest( &self, predicate: &Block<dyn Fn(NonNull<ObjectType>, NonNull<Bool>) -> Bool + '_> ) -> Retained<NSSet<ObjectType>>
block2
only.pub unsafe fn objectsWithOptions_passingTest( &self, opts: NSEnumerationOptions, predicate: &Block<dyn Fn(NonNull<ObjectType>, NonNull<Bool>) -> Bool + '_> ) -> Retained<NSSet<ObjectType>>
NSObjCRuntime
and block2
only.source§impl<ObjectType: Message> NSSet<ObjectType>
impl<ObjectType: Message> NSSet<ObjectType>
NSSetCreation
pub unsafe fn set() -> Retained<Self>
pub unsafe fn setWithObject(object: &ObjectType) -> Retained<Self>
pub unsafe fn setWithObjects_count( objects: NonNull<NonNull<ObjectType>>, cnt: NSUInteger ) -> Retained<Self>
pub unsafe fn setWithSet(set: &NSSet<ObjectType>) -> Retained<Self>
pub unsafe fn setWithArray(array: &NSArray<ObjectType>) -> Retained<Self>
NSArray
only.pub unsafe fn initWithSet( this: Allocated<Self>, set: &NSSet<ObjectType> ) -> Retained<Self>
pub unsafe fn initWithSet_copyItems( this: Allocated<Self>, set: &NSSet<ObjectType>, flag: bool ) -> Retained<Self>
pub unsafe fn initWithArray( this: Allocated<Self>, array: &NSArray<ObjectType> ) -> Retained<Self>
NSArray
only.source§impl<ObjectType: Message> NSSet<ObjectType>
impl<ObjectType: Message> NSSet<ObjectType>
NSSortDescriptorSorting
pub unsafe fn sortedArrayUsingDescriptors( &self, sort_descriptors: &NSArray<NSSortDescriptor> ) -> Retained<NSArray<ObjectType>>
NSSortDescriptor
and NSArray
only.source§impl<T: Message> NSSet<T>
impl<T: Message> NSSet<T>
source§impl<T: Message + Eq + Hash> NSSet<T>
impl<T: Message + Eq + Hash> NSSet<T>
sourcepub fn from_id_slice(slice: &[Retained<T>]) -> Retained<Self>where
T: HasStableHash + IsIdCloneable,
pub fn from_id_slice(slice: &[Retained<T>]) -> Retained<Self>where
T: HasStableHash + IsIdCloneable,
pub fn from_slice(slice: &[&T]) -> Retained<Self>where
T: HasStableHash + IsRetainable,
sourcepub fn to_vec(&self) -> Vec<&T>
Available on crate feature NSEnumerator
only.
pub fn to_vec(&self) -> Vec<&T>
NSEnumerator
only.Returns a Vec
containing the set’s elements.
§Examples
use objc2_foundation::{NSMutableString, NSSet};
let strs = vec![
NSMutableString::from_str("one"),
NSMutableString::from_str("two"),
NSMutableString::from_str("three"),
];
let set = NSSet::from_vec(strs);
let vec = set.to_vec();
assert_eq!(vec.len(), 3);
pub fn to_vec_retained(&self) -> Vec<Retained<T>>where
T: IsIdCloneable,
NSEnumerator
only.sourcepub fn to_array(&self) -> Retained<NSArray<T>>where
T: IsIdCloneable,
Available on crate feature NSArray
only.
pub fn to_array(&self) -> Retained<NSArray<T>>where
T: IsIdCloneable,
NSArray
only.Returns an NSArray
containing the set’s elements, or an empty
array if the set is empty.
§Examples
use objc2_foundation::{NSNumber, NSSet, NSString};
let nums = [1, 2, 3];
let set = NSSet::from_id_slice(&nums.map(NSNumber::new_i32));
assert_eq!(set.to_array().len(), 3);
assert!(set.to_array().iter().all(|i| nums.contains(&i.as_i32())));
source§impl<T: Message> NSSet<T>
impl<T: Message> NSSet<T>
sourcepub fn get_any(&self) -> Option<&T>
pub fn get_any(&self) -> Option<&T>
Returns a reference to one of the objects in the set, or None
if
the set is empty.
§Examples
use objc2_foundation::{NSSet, NSString};
let strs = ["one", "two", "three"].map(NSString::from_str);
let set = NSSet::from_id_slice(&strs);
let any = set.get_any().unwrap();
assert!(any == &*strs[0] || any == &*strs[1] || any == &*strs[2]);
source§impl<T: Message + Eq + Hash> NSSet<T>
impl<T: Message + Eq + Hash> NSSet<T>
sourcepub fn contains(&self, value: &T) -> bool
pub fn contains(&self, value: &T) -> bool
Returns true
if the set contains a value.
§Examples
use objc2_foundation::{ns_string, NSSet, NSString};
let strs = ["one", "two", "three"].map(NSString::from_str);
let set = NSSet::from_id_slice(&strs);
assert!(set.contains(ns_string!("one")));
sourcepub fn get(&self, value: &T) -> Option<&T>
pub fn get(&self, value: &T) -> Option<&T>
Returns a reference to the value in the set, if any, that is equal to the given value.
§Examples
use objc2_foundation::{ns_string, NSSet, NSString};
let strs = ["one", "two", "three"].map(NSString::from_str);
let set = NSSet::from_id_slice(&strs);
assert_eq!(set.get(ns_string!("one")), Some(&*strs[0]));
assert_eq!(set.get(ns_string!("four")), None);
pub fn get_retained(&self, value: &T) -> Option<Retained<T>>where
T: IsIdCloneable,
sourcepub fn is_subset(&self, other: &NSSet<T>) -> bool
pub fn is_subset(&self, other: &NSSet<T>) -> bool
Returns true
if the set is a subset of another, i.e., other
contains at least all the values in self
.
§Examples
use objc2_foundation::{NSSet, NSString};
let set1 = NSSet::from_id_slice(&["one", "two"].map(NSString::from_str));
let set2 = NSSet::from_id_slice(&["one", "two", "three"].map(NSString::from_str));
assert!(set1.is_subset(&set2));
assert!(!set2.is_subset(&set1));
sourcepub fn is_superset(&self, other: &NSSet<T>) -> bool
pub fn is_superset(&self, other: &NSSet<T>) -> bool
Returns true
if the set is a superset of another, i.e., self
contains at least all the values in other
.
§Examples
use objc2_foundation::{NSSet, NSString};
let set1 = NSSet::from_id_slice(&["one", "two"].map(NSString::from_str));
let set2 = NSSet::from_id_slice(&["one", "two", "three"].map(NSString::from_str));
assert!(!set1.is_superset(&set2));
assert!(set2.is_superset(&set1));
sourcepub fn is_disjoint(&self, other: &NSSet<T>) -> bool
pub fn is_disjoint(&self, other: &NSSet<T>) -> bool
Returns true
if self
has no elements in common with other
.
§Examples
use objc2_foundation::{NSSet, NSString};
let set1 = NSSet::from_id_slice(&["one", "two"].map(NSString::from_str));
let set2 = NSSet::from_id_slice(&["one", "two", "three"].map(NSString::from_str));
let set3 = NSSet::from_id_slice(&["four", "five", "six"].map(NSString::from_str));
assert!(!set1.is_disjoint(&set2));
assert!(set1.is_disjoint(&set3));
assert!(set2.is_disjoint(&set3));
source§impl<T: Message> NSSet<T>
impl<T: Message> NSSet<T>
sourcepub fn iter(&self) -> Iter<'_, T> ⓘ
Available on crate feature NSEnumerator
only.
pub fn iter(&self) -> Iter<'_, T> ⓘ
NSEnumerator
only.An iterator visiting all elements in arbitrary order.
§Examples
use objc2_foundation::{NSSet, NSString};
let strs = ["one", "two", "three"].map(NSString::from_str);
let set = NSSet::from_id_slice(&strs);
for s in &set {
println!("{s}");
}
pub fn iter_retained(&self) -> IterRetained<'_, T> ⓘwhere
T: IsIdCloneable,
NSEnumerator
only.Methods from Deref<Target = NSObject>§
sourcepub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
pub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
Handle messages the object doesn’t recognize.
See Apple’s documentation for details.
Methods from Deref<Target = AnyObject>§
sourcepub fn class(&self) -> &'static AnyClass
pub fn class(&self) -> &'static AnyClass
Dynamically find the class of this object.
§Example
Check that an instance of NSObject
has the precise class NSObject
.
use objc2::ClassType;
use objc2::runtime::NSObject;
let obj = NSObject::new();
assert_eq!(obj.class(), NSObject::class());
sourcepub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
👎Deprecated: this is difficult to use correctly, use Ivar::load
instead.
pub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
Ivar::load
instead.Use Ivar::load
instead.
§Safety
The object must have an instance variable with the given name, and it
must be of type T
.
See Ivar::load_ptr
for details surrounding this.
sourcepub unsafe fn get_mut_ivar<T>(&mut self, name: &str) -> &mut Twhere
T: Encode,
👎Deprecated: this is difficult to use correctly, use Ivar::load_mut
instead.
pub unsafe fn get_mut_ivar<T>(&mut self, name: &str) -> &mut Twhere
T: Encode,
Ivar::load_mut
instead.Use Ivar::load_mut
instead.
§Safety
The object must have an instance variable with the given name, and it
must be of type T
.
See Ivar::load_ptr
for details surrounding this.
Trait Implementations§
source§impl<ObjectType: ?Sized + Message> BorrowMut<AnyObject> for NSSet<ObjectType>
impl<ObjectType: ?Sized + Message> BorrowMut<AnyObject> for NSSet<ObjectType>
source§fn borrow_mut(&mut self) -> &mut AnyObject
fn borrow_mut(&mut self) -> &mut AnyObject
source§impl<ObjectType: ?Sized + Message> BorrowMut<NSObject> for NSSet<ObjectType>
impl<ObjectType: ?Sized + Message> BorrowMut<NSObject> for NSSet<ObjectType>
source§fn borrow_mut(&mut self) -> &mut NSObject
fn borrow_mut(&mut self) -> &mut NSObject
source§impl<ObjectType: ?Sized + Message> BorrowMut<NSSet<ObjectType>> for NSCountedSet<ObjectType>
impl<ObjectType: ?Sized + Message> BorrowMut<NSSet<ObjectType>> for NSCountedSet<ObjectType>
source§fn borrow_mut(&mut self) -> &mut NSSet<ObjectType>
fn borrow_mut(&mut self) -> &mut NSSet<ObjectType>
source§impl<ObjectType: ?Sized + Message> BorrowMut<NSSet<ObjectType>> for NSMutableSet<ObjectType>
impl<ObjectType: ?Sized + Message> BorrowMut<NSSet<ObjectType>> for NSMutableSet<ObjectType>
source§fn borrow_mut(&mut self) -> &mut NSSet<ObjectType>
fn borrow_mut(&mut self) -> &mut NSSet<ObjectType>
source§impl<ObjectType: ?Sized + Message> ClassType for NSSet<ObjectType>
impl<ObjectType: ?Sized + Message> ClassType for NSSet<ObjectType>
§type Mutability = ImmutableWithMutableSubclass<NSMutableSet<ObjectType>>
type Mutability = ImmutableWithMutableSubclass<NSMutableSet<ObjectType>>
source§const NAME: &'static str = "NSSet"
const NAME: &'static str = "NSSet"
source§fn class() -> &'static AnyClass
fn class() -> &'static AnyClass
source§fn as_super_mut(&mut self) -> &mut Self::Super
fn as_super_mut(&mut self) -> &mut Self::Super
source§impl<ObjectType: Message> DefaultRetained for NSSet<ObjectType>
impl<ObjectType: Message> DefaultRetained for NSSet<ObjectType>
source§impl<'a, T: Message> IntoIterator for &'a NSSet<T>
impl<'a, T: Message> IntoIterator for &'a NSSet<T>
source§impl<ObjectType: PartialEq + ?Sized> PartialEq for NSSet<ObjectType>
impl<ObjectType: PartialEq + ?Sized> PartialEq for NSSet<ObjectType>
source§impl<ObjectType: ?Sized + Message> RefEncode for NSSet<ObjectType>
impl<ObjectType: ?Sized + Message> RefEncode for NSSet<ObjectType>
source§const ENCODING_REF: Encoding = <NSObject as ::objc2::RefEncode>::ENCODING_REF
const ENCODING_REF: Encoding = <NSObject as ::objc2::RefEncode>::ENCODING_REF
source§impl<'a, T: Message + Eq + Hash + HasStableHash + IsRetainable + 'a> RetainedFromIterator<&'a T> for NSSet<T>
impl<'a, T: Message + Eq + Hash + HasStableHash + IsRetainable + 'a> RetainedFromIterator<&'a T> for NSSet<T>
source§fn id_from_iter<I: IntoIterator<Item = &'a T>>(iter: I) -> Retained<Self>
fn id_from_iter<I: IntoIterator<Item = &'a T>>(iter: I) -> Retained<Self>
Retained
from an iterator. Read moresource§fn retained_from_iter<I>(iter: I) -> Retained<Self>where
I: IntoIterator<Item = T>,
fn retained_from_iter<I>(iter: I) -> Retained<Self>where
I: IntoIterator<Item = T>,
Retained
from an iterator.source§impl<T: Message + Eq + Hash + HasStableHash> RetainedFromIterator<Retained<T>> for NSSet<T>
impl<T: Message + Eq + Hash + HasStableHash> RetainedFromIterator<Retained<T>> for NSSet<T>
source§fn id_from_iter<I: IntoIterator<Item = Retained<T>>>(iter: I) -> Retained<Self>
fn id_from_iter<I: IntoIterator<Item = Retained<T>>>(iter: I) -> Retained<Self>
Retained
from an iterator. Read moresource§fn retained_from_iter<I>(iter: I) -> Retained<Self>where
I: IntoIterator<Item = T>,
fn retained_from_iter<I>(iter: I) -> Retained<Self>where
I: IntoIterator<Item = T>,
Retained
from an iterator.source§impl<T: Message + IsIdCloneable> RetainedIntoIterator for NSSet<T>
impl<T: Message + IsIdCloneable> RetainedIntoIterator for NSSet<T>
source§fn id_into_iter(this: Retained<Self>) -> Self::IntoIter
fn id_into_iter(this: Retained<Self>) -> Self::IntoIter
source§impl<T: Message + IsIdCloneable> ToOwned for NSSet<T>
Available on crate feature NSObject
only.
impl<T: Message + IsIdCloneable> ToOwned for NSSet<T>
NSObject
only.impl<ObjectType: Eq + ?Sized> Eq for NSSet<ObjectType>
impl<ObjectType: ?Sized + Message> Message for NSSet<ObjectType>
impl<ObjectType: ?Sized + NSCoding> NSCoding for NSSet<ObjectType>
NSObject
only.impl<ObjectType: ?Sized + IsIdCloneable> NSCopying for NSSet<ObjectType>
NSObject
only.impl<ObjectType: ?Sized> NSFastEnumeration for NSSet<ObjectType>
NSEnumerator
only.impl<ObjectType: ?Sized + IsIdCloneable> NSMutableCopying for NSSet<ObjectType>
NSObject
only.impl<ObjectType: ?Sized> NSObjectProtocol for NSSet<ObjectType>
impl<ObjectType: ?Sized + NSSecureCoding> NSSecureCoding for NSSet<ObjectType>
NSObject
only.