title: Singleton NSMutableDictionary property won't allow setObject:forKey
body: <p>I have a complete noob question for you. I'm obviously rusty with obj-c. I have a simple shopping cart class implemented as a singleton and just want it to store a single NSMutableDictionary. I want to be able to add objects to this dictionary from anywhere in the app. But for some (I'm sure simple) reason it's just returning null. No error messages.</p>
  
  <p><strong>ShoppingCart.h:</strong></p>
  
  <pre><code>#import &lt;Foundation/Foundation.h&gt;
  
  @interface ShoppingCart : NSObject
  
  // This is the only thing I'm storing here.
  @property (nonatomic, strong) NSMutableDictionary *items;
  
  + (ShoppingCart *)sharedInstance;
  
  @end
  </code></pre>
  
  <p><strong>ShoppingCart.m:</strong></p>
  
  <pre><code>// Typical singelton.
  #import "ShoppingCart.h"
  
  @implementation ShoppingCart
  
  static ShoppingCart *sharedInstance = nil;
  
  + (ShoppingCart *)sharedInstance
  {
      @synchronized(self)
      {
          if (sharedInstance == nil)
              sharedInstance = [[self alloc] init];
      }
      return(sharedInstance);
  }
  
  @end
  </code></pre>
  
  <p><strong>And in my VC I'm trying to set it with:</strong></p>
  
  <pre><code>- (IBAction)addToCartButton:(id)sender
  {
      NSDictionary *thisItem = [[NSDictionary alloc] initWithObjects:@[@"test", @"100101", @"This is a test products description"] forKeys:@[@"name", @"sku", @"desc"]];
  
      // This is what's failing.
      [[ShoppingCart sharedInstance].items setObject:thisItem forKey:@"test"]; 
  
      // But this works.
      [ShoppingCart sharedInstance].items = (NSMutableDictionary *)thisItem; 
  
      // This logs null. Specifically "(null) has been added to the cart"
      DDLogCInfo(@"%@ has been added to the cart", [[ShoppingCart sharedInstance] items]); 
  }
  </code></pre>
  
  <p>Thanks</p>