pub trait INSCopying: INSObject {
type Output: INSObject;
// Provided method
fn copy(&self) -> ShareId<Self::Output> { ... }
}
Required Associated Types§
Provided Methods§
Sourcefn copy(&self) -> ShareId<Self::Output>
fn copy(&self) -> ShareId<Self::Output>
Examples found in repository?
examples/example.rs (line 29)
6fn main() {
7 // Create and compare NSObjects
8 let obj = NSObject::new();
9 println!("{:?} == {:?}? {:?}", obj, obj, obj == obj);
10
11 let obj2 = NSObject::new();
12 println!("{:?} == {:?}? {:?}", obj, obj2, obj == obj2);
13
14 // Create an NSArray from a Vec
15 let objs = vec![obj, obj2];
16 let array = NSArray::from_vec(objs);
17 for obj in array.object_enumerator() {
18 println!("{:?}", obj);
19 }
20 println!("{}", array.count());
21
22 // Turn the NSArray back into a Vec
23 let mut objs = NSArray::into_vec(array);
24 let obj = objs.pop().unwrap();
25
26 // Create an NSString from a str slice
27 let string = NSString::from_str("Hello, world!");
28 println!("{}", string.as_str());
29 let string2 = string.copy();
30 println!("{}", string2.as_str());
31
32 // Create a dictionary mapping strings to objects
33 let keys = &[&*string];
34 let vals = vec![obj];
35 let dict = NSDictionary::from_keys_and_objects(keys, vals);
36 println!("{:?}", dict.object_for(&string));
37 println!("{}", dict.count());
38}
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.