@@ -29,31 +29,33 @@ unsafe {
2929
3030The utilities of the ` rc `  module provide ARC-like semantics for working with
3131Objective-C's reference counted objects in Rust.
32- A ` StrongPtr `  retains an object and releases the object when dropped.
33- A ` WeakPtr `  will not retain the object, but can be upgraded to a ` StrongPtr ` 
34- and safely fails if the object has been deallocated.
32+ 
33+ An ` Id `  retains an object and releases the object when dropped.
34+ A ` WeakId `  will not retain the object, but can be upgraded to an ` Id `  and
35+ safely fails if the object has been deallocated.
3536
3637``` rust  , no_run
3738use  objc2 :: {class, msg_send};
38- use  objc2 :: rc :: {autoreleasepool, StrongPtr };
39+ use  objc2 :: rc :: {autoreleasepool, Id , Shared , WeakId };
40+ use  objc2 :: runtime :: Object ;
3941
40- //  StrongPtr  will release the object when dropped
41- let  obj  =  unsafe  {
42-     StrongPtr :: new (msg_send! [class! (NSObject ), new ])
42+ //  Id  will release the object when dropped
43+ let  obj :   Id < Object ,  Shared >  =  unsafe  {
44+     Id :: new (msg_send! [class! (NSObject ), new ])
4345};
4446
4547//  Cloning retains the object an additional time
4648let  cloned  =  obj . clone ();
47- autoreleasepool (| _ |  {
48-     //  Autorelease consumes the StrongPtr , but won't
49+ autoreleasepool (| pool |  {
50+     //  Autorelease consumes the Id , but won't
4951    //  actually release until the end of an autoreleasepool
50-     cloned . autorelease ();
52+     let   obj_ref :   & Object   =   cloned . autorelease (pool );
5153});
5254
5355//  Weak references won't retain the object
54- let  weak  =  obj . weak ( );
56+ let  weak  =  WeakId :: new ( & obj );
5557drop (obj );
56- assert! (weak . load (). is_null ());
58+ assert! (weak . load (). is_none ());
5759``` 
5860
5961## Declaring classes  
0 commit comments