title: Pass object with NSNotificationCenter to other view
body: <p>I am trying to pass an object from my main view class to other notification receiver in another class.</p>
  
  <p>I want to pass an object named country, that loads all the cities from an SOAP Request in the Main Controller and i want to send it to my next view.</p>
  
  <blockquote>
    <p>country = [[Country alloc] init];</p>
  </blockquote>
  
  <p>Country header:</p>
  
  <pre><code>@interface Country : NSObject
  {
      NSString *name;
      NSMutableArray *cities;
  }
  
  @property (nonatomic,retain) NSString *name;
  
  - (void)addCity:(Cities *)city;
  - (NSArray *)getCities;
  - (int)citiesCount;    
  @end
  </code></pre>
  
  <p>I found a way to pass data with NSNotificatios is using a NSDictionary in UserInfo. But its not possible to send the whole object instead of converting to an NSDictionary? Or what's the best way to transfer it? Im stuck trying to figure out how to pass the objects.</p>
  
  <p>Actually i got working this simple NSNotification on my App.</p>
  
  <p>NSNotification in the Main View Controller implementation:</p>
  
  <pre><code>//---Call the next View---
  DetailViewController *detail = [self.storyboardinstantiateViewControllerWithIdentifier:@"Detail"];
  [self.navigationController pushViewController:detail animated:YES]; 
  
  //--Transfer Data to2View 
  [[NSNotificationCenter defaultCenter] postNotificationName:@"citiesListComplete" object:nil];
  </code></pre>
  
  <p>NSNotification in 2View Controller implementation:</p>
  
  <pre><code> // Check if MSG is RECEIVE
  - (void)checkMSG:(NSNotification *)note {
  
      NSLog(@"Received Notification");
  }
  
  - (void)viewDidLoad
  {
      [[NSNotificationCenter defaultCenter] addObserver:self 
                                               selector:@selector(checkMSG:) 
                                                   name:@"citiesListComplete" object:nil];
  </code></pre>