title: ARC doesn't work properly in Xcode with Objective-C
body: <p>I have a dilemma with strong and weak references in Xcode with Obj-C. 
  When I create two objects with cross-references to each other inside, all weak:</p>
  
  <pre><code> Mouse *mouse = [[Mouse alloc] initWithComputer:nil];
   Computer *computer = [[Computer alloc] initWithMouse:mouse];
  
   NSLog(@"%@", computer.mouse);  //prints legit address
  
   mouse = nil;  //destroy the ONLY strong reference to Mouse
  
   NSLog(@"%@", computer.mouse); //still prints(holds) the same legit address 
  </code></pre>
  
  <p>Before  <strong>mouse = nil;</strong></p>
  
  <p><a href="https://i.stack.imgur.com/Zr83p.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Zr83p.png" alt="enter image description here"></a></p>
  
  <p>After  <strong>mouse = nil;</strong></p>
  
  <p><a href="https://i.stack.imgur.com/id1Se.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/id1Se.png" alt="enter image description here"></a></p>
  
  <p>After "destroying" the ONLY strong reference to <strong>Mouse class mouse</strong>, an instance of Mouse <strong>computer.mouse</strong> still holds the same memory address when it should be deallocated.</p>
  
  <p>Absolutely the same code only in SWIFT in Xcode works correctly and deallocates the memory being held by <strong>computer.mouse</strong> making it <strong>nil</strong></p>
  
  <p>Is anything wrong with my Obj-c code? My Xcode is up to date, though with the previous version I had no luck either in Obj-c. I would appreciate any help.  </p>
  
  <p>Here are my classes:</p>
  
  <p>Computer.h</p>
  
  <pre><code>#import &lt;Foundation/Foundation.h&gt;
  @class Mouse;
  
  @interface Computer : NSObject
  
  @property (nonatomic, weak) Mouse *mouse;
  
  - (instancetype) initWithMouse: (Mouse *) userPutMouse ;
  
  @end
  </code></pre>
  
  <p>Computer.m</p>
  
  <pre><code>#import "Computer.h"
  #import "Mouse.h"
  
  @implementation Computer
  
  - (instancetype) initWithMouse: (Mouse *) userPutMouse {
  
      self = [super init];
  
      if (self) {
  
          self.mouse = userPutMouse;
          self.mouse.computer = self;
  
      }
  
      return self;
  }
  
  @end
  </code></pre>
  
  <p>Mouse.h</p>
  
  <pre><code>#import &lt;Foundation/Foundation.h&gt;
  @class Computer;
  
  @interface Mouse : NSObject 
  
  @property (nonatomic, weak) Computer *computer;
  
  - (instancetype) initWithComputer: (Computer *) userPutComputer;
  
  @end
  </code></pre>
  
  <p>Mouse.m</p>
  
  <pre><code>#import "Mouse.h"
  #import "Computer.h"
  
  @implementation Mouse
  
  - (instancetype) initWithComputer: (Computer *) userPutComputer {
  
      self = [super init];
  
      if (self ) {
  
          if (userPutComputer) {
              self.computer = userPutComputer;
          }
  
      }
  
      return self;
  }
  
  @end
  </code></pre>