title: How can I save a JSON string to the NSUserDefaults?
body: <p>I have a JSON request which returns different parameters, name for example. I would like to cache a variable for the name parameter, which I can view in the app later.</p>
  
  <p>For example: name from JSON request = david. the variable is called firstname. firstname should equal "david". firstname should be stored so I can view it in all parts of my apps.</p>
  
  <p>I saw another similar question were one solution was:</p>
  
  <pre><code>NSString *valueToSave = @"someValue";
  [[NSUserDefaults standardUserDefaults]
      setObject:valueToSave forKey:@"preferenceName"];
  </code></pre>
  
  <p>and to get it back later:</p>
  
  <pre><code>NSString *savedValue = [[NSUserDefaults standardUserDefaults]
      stringForKey:@"preferenceName"];
  </code></pre>
  
  <p>How can I use this method when I'm parsing a JSON file like this?:</p>
  
  <pre><code>@implementation Videos
  
  @synthesize tableView = _tableView, activityIndicatorView = _activityIndicatorView, movies = _movies;
  
  - (void)viewDidLoad
  {
      [super viewDidLoad];
  
      self.title = @"Title";
      self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Menu"
                                                                               style:UIBarButtonItemStylePlain
                                                                              target:(DEMONavigationController *)self.navigationController
                                                                              action:@selector(showMenu)];
  
  
      NSString *valueToSave = @"TitleString";
      [[NSUserDefaults standardUserDefaults]
       setObject:valueToSave forKey:@"title"];
  
      self.tableView.separatorColor = [UIColor clearColor];
  
      // Setting Up Activity Indicator View
      self.activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
      self.activityIndicatorView.hidesWhenStopped = YES;
      self.activityIndicatorView.center = self.view.center;
      [self.view addSubview:self.activityIndicatorView];
      [self.activityIndicatorView startAnimating];
      self.tableView.separatorColor = [UIColor clearColor];
  
      // Initializing Data Source
      self.movies = [[NSArray alloc] init];
  
      NSURL *url = [[NSURL alloc] initWithString:@"http://link-to-json.php?name=Name"];
      NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
  
      AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
          self.movies = JSON;
          [self.activityIndicatorView stopAnimating];
          [self.tableView reloadData];
  
      } failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) {
          NSLog(@"Request Failed with Error: %@, %@", error, error.userInfo);
      }];
  
      [operation start];
  
  }
  
  // Table View Data Source Methods
  - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
      if (self.movies &amp;&amp; self.movies.count) {
          return self.movies.count;
      } else {
          return 0;
      }
  }
  
  - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  {
      return 374;
  }
  
  - (void)tableView:(UITableView *)tableView
    willDisplayCell:(UITableViewCell *)cell
  forRowAtIndexPath:(NSIndexPath *)indexPath
  {
      [cell setBackgroundColor:[UIColor clearColor]];
  }
  
  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
      static NSString *simpleTableIdentifier = @"VideosObject";
  
      VideosObject *cell = (VideosObject *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
      if (cell == nil)
      {
          NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"VideosObject" owner:self options:nil];
          cell = [nib objectAtIndex:0];
          cell.selectionStyle = UITableViewCellSelectionStyleNone;
  
          UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Purple Sunrise Pattern iPhone 5 Wallpaper.png"]];
  
          self.tableView.backgroundView = imageView;
      }
  
      NSDictionary *movie = [self.movies objectAtIndex:indexPath.row];
      cell.title.text = [movie objectForKey:@"title"];
  
      NSURL *url = [[NSURL alloc] initWithString:[movie objectForKey:@"link"]];
      [cell.pic setImageWithURL:url placeholderImage:[UIImage imageNamed:@"placeholder"]];
  
      return cell;
  }
  
  @end
  </code></pre>