pub trait INSArray: INSObject {
type Item: INSObject;
type Own: Ownership;
Show 13 methods
// Provided methods
fn count(&self) -> usize { ... }
fn object_at(&self, index: usize) -> &Self::Item { ... }
fn first_object(&self) -> Option<&Self::Item> { ... }
fn last_object(&self) -> Option<&Self::Item> { ... }
fn object_enumerator(&self) -> NSEnumerator<'_, Self::Item> ⓘ { ... }
fn from_vec(vec: Vec<Id<Self::Item, Self::Own>>) -> Id<Self> { ... }
fn objects_in_range(&self, range: Range<usize>) -> Vec<&Self::Item> { ... }
fn to_vec(&self) -> Vec<&Self::Item> { ... }
fn into_vec(array: Id<Self>) -> Vec<Id<Self::Item, Self::Own>> { ... }
fn mut_object_at(&mut self, index: usize) -> &mut Self::Item
where Self: INSArray<Own = Owned> { ... }
fn shared_object_at(&self, index: usize) -> ShareId<Self::Item>
where Self: INSArray<Own = Shared> { ... }
fn from_slice(slice: &[ShareId<Self::Item>]) -> Id<Self>
where Self: INSArray<Own = Shared> { ... }
fn to_shared_vec(&self) -> Vec<ShareId<Self::Item>>
where Self: INSArray<Own = Shared> { ... }
}
Required Associated Types§
Provided Methods§
Sourcefn count(&self) -> usize
fn count(&self) -> usize
Examples found in repository?
examples/example.rs (line 20)
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 object_at(&self, index: usize) -> &Self::Item
fn first_object(&self) -> Option<&Self::Item>
fn last_object(&self) -> Option<&Self::Item>
Sourcefn object_enumerator(&self) -> NSEnumerator<'_, Self::Item> ⓘ
fn object_enumerator(&self) -> NSEnumerator<'_, Self::Item> ⓘ
Examples found in repository?
examples/example.rs (line 17)
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 from_vec(vec: Vec<Id<Self::Item, Self::Own>>) -> Id<Self>
fn from_vec(vec: Vec<Id<Self::Item, Self::Own>>) -> Id<Self>
Examples found in repository?
examples/example.rs (line 16)
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 objects_in_range(&self, range: Range<usize>) -> Vec<&Self::Item>
fn to_vec(&self) -> Vec<&Self::Item>
Sourcefn into_vec(array: Id<Self>) -> Vec<Id<Self::Item, Self::Own>>
fn into_vec(array: Id<Self>) -> Vec<Id<Self::Item, Self::Own>>
Examples found in repository?
examples/example.rs (line 23)
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 mut_object_at(&mut self, index: usize) -> &mut Self::Item
fn from_slice(slice: &[ShareId<Self::Item>]) -> Id<Self>
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.