title: Accessing NSDictionary in Singleton Class w/o Creating Copies
body: <p>I have a singleton as follows, which creates an instance of NSDictionary to hold my data.  Here is the .h:</p>
  
  <pre><code>@interface FirstLast : NSObject
  
  @property (strong, nonatomic, readonly) NSArray *firstArray;
  @property (strong, nonatomic, readonly) NSArray *lastArray;
  @property (strong, nonatomic, readonly) NSDictionary *fl;
  
  + (FirstLast *) firstLast;
  - (NSDictionary *) tempDic;
  
  @end
  </code></pre>
  
  <p>Here is the .m</p>
  
  <pre><code>@implementation FirstLast
  
  @synthesize firstArray = _firstArray;
  @synthesize lastArray = _lastArray;
  @synthesize fl = _fl;
  
  + (FirstLast *)firstLast {
      static FirstLast *singleton;
      static dispatch_once_t once;
      dispatch_once(&amp;once, ^{
          singleton = [[FirstLast alloc] init];
          NSLog(@"FirstLast instantiated");
      });
      return singleton;
  }
  
  - (NSDictionary *) tempDic{
  
      _firstArray = [[NSArray alloc] initWithObjects:@"Bob", @"Joe", @"Sally", @"Sue", nil];
      _lastArray = [[NSArray alloc] initWithObjects:@"Jones", @"Johnson", @"Thompson", @"Miller", nil];
      _fl = [NSDictionary dictionaryWithObjects:_firstArray
                                      forKeys:_lastArray];
      NSLog(@"tempDic just made _fl at this address");
      NSLog(@"%p", _fl);
      return _fl;
  }
  
  @end
  </code></pre>
  
  <p>All of this works fine. In the view controller I instantiate all this for the first time (works fine too):</p>
  
  <pre><code> NSLog(@"VC is setting up tempDic");
  
   [[WordsClues wordsClues] tempDic];
  </code></pre>
  
  <p>When I try to gain access to tempDic elsewhere, like this:</p>
  
  <pre><code>NSInteger rIndex = arc4random_uniform(4) + 1;
  NSString *fname = [[[FirstLast firstLast].tempDic allValues] objectAtIndex:rIndex];
  </code></pre>
  
  <p>it works fine, but, when I repeat this process, each time I'm creating a new tempDic.  I know this because the NSLog giving the address gives a different answer each time.  I really want to access the existing dictionary, which is what I thought my singleton was going to accomplish. Clearly I'm either not accessing tempDic correctly or I misunderstand what the singleton can do for me or I have the tempDic set up wrong.  The goal is to get a random value from a single copy of tempDic and not write local copies of tempDic all over the place.  Thanks.</p>