pub trait INSDictionary: INSObject {
type Key: INSObject;
type Value: INSObject;
type Own: Ownership;
// Provided methods
fn count(&self) -> usize { ... }
fn object_for(&self, key: &Self::Key) -> Option<&Self::Value> { ... }
fn keys(&self) -> Vec<&Self::Key> { ... }
fn values(&self) -> Vec<&Self::Value> { ... }
fn keys_and_objects(&self) -> (Vec<&Self::Key>, Vec<&Self::Value>) { ... }
fn key_enumerator(&self) -> NSEnumerator<'_, Self::Key> ⓘ { ... }
fn object_enumerator(&self) -> NSEnumerator<'_, Self::Value> ⓘ { ... }
fn keys_array(&self) -> Id<NSSharedArray<Self::Key>> { ... }
fn from_keys_and_objects<T>(
keys: &[&T],
vals: Vec<Id<Self::Value, Self::Own>>,
) -> Id<Self>
where T: INSCopying<Output = Self::Key> { ... }
fn into_values_array(dict: Id<Self>) -> Id<NSArray<Self::Value, Self::Own>> { ... }
}
Required Associated Types§
Provided Methods§
Sourcefn count(&self) -> usize
fn count(&self) -> usize
Examples found in repository?
examples/example.rs (line 37)
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
fn main() {
// Create and compare NSObjects
let obj = NSObject::new();
println!("{:?} == {:?}? {:?}", obj, obj, obj == obj);
let obj2 = NSObject::new();
println!("{:?} == {:?}? {:?}", obj, obj2, obj == obj2);
// Create an NSArray from a Vec
let objs = vec![obj, obj2];
let array = NSArray::from_vec(objs);
for obj in array.object_enumerator() {
println!("{:?}", obj);
}
println!("{}", array.count());
// Turn the NSArray back into a Vec
let mut objs = NSArray::into_vec(array);
let obj = objs.pop().unwrap();
// Create an NSString from a str slice
let string = NSString::from_str("Hello, world!");
println!("{}", string.as_str());
let string2 = string.copy();
println!("{}", string2.as_str());
// Create a dictionary mapping strings to objects
let keys = &[&*string];
let vals = vec![obj];
let dict = NSDictionary::from_keys_and_objects(keys, vals);
println!("{:?}", dict.object_for(&string));
println!("{}", dict.count());
}
Sourcefn object_for(&self, key: &Self::Key) -> Option<&Self::Value>
fn object_for(&self, key: &Self::Key) -> Option<&Self::Value>
Examples found in repository?
examples/example.rs (line 36)
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
fn main() {
// Create and compare NSObjects
let obj = NSObject::new();
println!("{:?} == {:?}? {:?}", obj, obj, obj == obj);
let obj2 = NSObject::new();
println!("{:?} == {:?}? {:?}", obj, obj2, obj == obj2);
// Create an NSArray from a Vec
let objs = vec![obj, obj2];
let array = NSArray::from_vec(objs);
for obj in array.object_enumerator() {
println!("{:?}", obj);
}
println!("{}", array.count());
// Turn the NSArray back into a Vec
let mut objs = NSArray::into_vec(array);
let obj = objs.pop().unwrap();
// Create an NSString from a str slice
let string = NSString::from_str("Hello, world!");
println!("{}", string.as_str());
let string2 = string.copy();
println!("{}", string2.as_str());
// Create a dictionary mapping strings to objects
let keys = &[&*string];
let vals = vec![obj];
let dict = NSDictionary::from_keys_and_objects(keys, vals);
println!("{:?}", dict.object_for(&string));
println!("{}", dict.count());
}
fn keys(&self) -> Vec<&Self::Key>
fn values(&self) -> Vec<&Self::Value>
fn keys_and_objects(&self) -> (Vec<&Self::Key>, Vec<&Self::Value>)
fn key_enumerator(&self) -> NSEnumerator<'_, Self::Key> ⓘ
fn object_enumerator(&self) -> NSEnumerator<'_, Self::Value> ⓘ
fn keys_array(&self) -> Id<NSSharedArray<Self::Key>>
Sourcefn from_keys_and_objects<T>(
keys: &[&T],
vals: Vec<Id<Self::Value, Self::Own>>,
) -> Id<Self>where
T: INSCopying<Output = Self::Key>,
fn from_keys_and_objects<T>(
keys: &[&T],
vals: Vec<Id<Self::Value, Self::Own>>,
) -> Id<Self>where
T: INSCopying<Output = Self::Key>,
Examples found in repository?
examples/example.rs (line 35)
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
fn main() {
// Create and compare NSObjects
let obj = NSObject::new();
println!("{:?} == {:?}? {:?}", obj, obj, obj == obj);
let obj2 = NSObject::new();
println!("{:?} == {:?}? {:?}", obj, obj2, obj == obj2);
// Create an NSArray from a Vec
let objs = vec![obj, obj2];
let array = NSArray::from_vec(objs);
for obj in array.object_enumerator() {
println!("{:?}", obj);
}
println!("{}", array.count());
// Turn the NSArray back into a Vec
let mut objs = NSArray::into_vec(array);
let obj = objs.pop().unwrap();
// Create an NSString from a str slice
let string = NSString::from_str("Hello, world!");
println!("{}", string.as_str());
let string2 = string.copy();
println!("{}", string2.as_str());
// Create a dictionary mapping strings to objects
let keys = &[&*string];
let vals = vec![obj];
let dict = NSDictionary::from_keys_and_objects(keys, vals);
println!("{:?}", dict.object_for(&string));
println!("{}", dict.count());
}
fn into_values_array(dict: Id<Self>) -> Id<NSArray<Self::Value, Self::Own>>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.