title: UserDefaults between Objective-C and Swift
body: <p>Just trying to be extra careful here...</p>
  
  <p>If I have an app that saved a value in UserDefaults like this in Objective-C:</p>
  
  <pre><code>NSString *newString = textField.text;
  [[NSUserDefaults standardUserDefaults] setObject: newString forKey:@"textKey"];
  </code></pre>
  
  <p>Would this be the proper way of checking whether this value exists when I release an update to the app that is now coded in Swift:</p>
  
  <pre><code>if (UserDefaults.standard.object(forKey: "textKey") as? String) != nil {
       print("There is a string")
  } else {
       print("No string exists") 
  }
  </code></pre>
  
  <p>I try to use .string(forKey:) and .bool(forKey:) since they've been introduced, but is it safest since this was saved as an object to pull it out as an object and then test it with "as? String"?</p>
  
  <p>Trickier version of the same question:</p>
  
  <p>An NSMutableArray of NSDictionary objects was saved as an object in UserDefaults</p>
  
  <pre><code>if let oldData = UserDefaults.standard.object(forKey: "theData") as? [NSMutableDictionary] {
  
  }
  </code></pre>
  
  <p>Will NSDictionary and NSMutableDictionary be interchangeable here?</p>
  
  <p>Thanks!</p>