pub trait INSString: INSObject {
// Provided methods
fn len(&self) -> usize { ... }
fn as_str(&self) -> &str { ... }
fn from_str(string: &str) -> Id<Self> { ... }
}
Provided Methods§
fn len(&self) -> usize
Sourcefn as_str(&self) -> &str
fn as_str(&self) -> &str
Examples found in repository?
examples/example.rs (line 28)
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_str(string: &str) -> Id<Self>
fn from_str(string: &str) -> Id<Self>
Examples found in repository?
examples/example.rs (line 27)
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());
}
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.