title: Replace occurrences of NSNull in nested NSDictionary
body: <p>This question is similar to <a href="https://stackoverflow.com/questions/8075147/replace-all-nsnull-objects-in-an-nsdictionary">this question</a>, however this method only works on the root level of the dictionary.</p>
  
  <p>I'm looking to replace any occurrence of <code>NSNull</code> values with an empty string, so that I can save the full dictionary to a plist file (if i add it with the NSNull's the file won't write).</p>
  
  <p>My dictionary, however, has nested dictionaries inside it. Like this:</p>
  
  <pre><code>"dictKeyName" = {
      innerStrKeyName = "This is a string in a dictionary";
      innerNullKeyName = "&lt;null&gt;";
      innerDictKeyName = {
          "innerDictStrKeyName" = "This is a string in a Dictionary in another Dictionary";
          "innerDictNullKeyName" = "&lt;null&gt;";
      };
  };
  </code></pre>
  
  <p>If I use:</p>
  
  <pre><code>@interface NSDictionary (JRAdditions)
  - (NSDictionary *) dictionaryByReplacingNullsWithStrings;
  @end
  
  @implementation NSDictionary (JRAdditions)
  
  - (NSDictionary *) dictionaryByReplacingNullsWithStrings {
  
      const NSMutableDictionary *replaced = [NSMutableDictionary dictionaryWithDictionary:self];
      const id nul = [NSNull null];
      const NSString *blank = @"";
  
      for(NSString *key in replaced) {
          const id object = [self objectForKey:key];
          if(object == nul) {
              [replaced setObject:blank forKey:key];
          }
      }
      return [NSDictionary dictionaryWithDictionary:replaced];
  }
  
  @end
  </code></pre>
  
  <p>I get something like this:</p>
  
  <pre><code>"dictKeyName" = {
      innerStrKeyName = "This is a string in a dictionary";
      innerNullKeyName = ""; &lt;-- this value has changed
      innerDictKeyName = {
          "innerDictStrKeyName" = "This is a string in a Dictionary in another Dictionary";
          "innerDictNullKeyName" = "&lt;null&gt;"; &lt;-- this value hasn't changed
      };
  };
  </code></pre>
  
  <p>Is there a way of finding every <code>NSNull</code> value from all dictionaries including nested dictionaries...?</p>
  
  <p><strong>EDIT:</strong>
  The data is being drawn from a JSON feed, so the data I receive is dynamic (and I don't want to have to update the app everytime the feed changes).</p>