title: Objective C assigning a dictionary to a variable and accessing it
body: <p>I'm sorry to ask this question again, but I'm still stuck.</p>
  
  <p>I have a city object trying to fetch weather from a weather fetcher object </p>
  
  <pre><code>@interface WeatherFetcher : NSObject {
  
  }
  
  @property (nonatomic, strong) NSMutableDictionary *weatherData;
  
  - (void)fetchWeather:(NSString *)cityName;
  - (void)handleNetworkErorr:(NSError *)error;
  - (void)handleNetworkResponse:(NSData *)myData;
  
  @end
  </code></pre>
  
  <p>This is were I assign the value to weatherData</p>
  
  <pre><code>#import "WeatherFetcher.h"
  
  @implementation WeatherFetcher
  
  - (void)fetchWeather:(NSString *)cityName
  {
      NSString *urlString = @"http://api.openweathermap.org/data/2.5/weather?q=";
      urlString = [urlString stringByAppendingString:cityName];
      urlString = [urlString stringByAppendingString:@",Aus"];
  
      NSURL *url = [NSURL URLWithString:urlString];
      NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
  
      [NSURLConnection sendAsynchronousRequest:request
                                         queue:[NSOperationQueue mainQueue]
                             completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
                                 if (connectionError)
                                 {
                                     [self handleNetworkErorr:connectionError];
                                 }
                                 else
                                 {
                                     [self handleNetworkResponse:data];
                                 }
                             }];
  }
  
  #pragma mark - Private Failure Methods
  
  - (void)handleNetworkErorr:(NSError *)error
  {
      UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Network Error" message:@"Please try again later" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
  
      [alert show];
  }
  
  #pragma mark - Private Success Methods
  
  - (void)handleNetworkResponse:(NSData *)myData
  {
      //NSMutableDictionary *data = [NSMutableDictionary dictionary];
      NSMutableDictionary *data = [[NSMutableDictionary alloc] init];
  
      // now we'll parse our data using NSJSONSerialization
      id myJSON = [NSJSONSerialization JSONObjectWithData:myData options:NSJSONReadingMutableContainers error:nil];
  
      // typecast an array and list its contents
      NSDictionary *jsonArray = (NSDictionary *)myJSON;
  
      //NSLog([jsonArray description]);
  
      // take a look at all elements in the array
      for (id element in jsonArray) {
  
          id key = [element description];
  
          id innerArr = [jsonArray objectForKey:key];
  
          NSDictionary *inner = (NSDictionary *)innerArr;
  
          if ([inner conformsToProtocol:@protocol(NSFastEnumeration)]) {
  
              for(id ele in inner) {
  
                  if ([ele conformsToProtocol:@protocol(NSFastEnumeration)]) {
  
                      NSDictionary *innerInner = (NSDictionary *)ele;
  
                      for(id eleEle in innerInner) {
  
                          id innerInnerKey = [eleEle description];
                          [data setObject:[[inner valueForKey:innerInnerKey] description] forKey:[eleEle description]];
                      }
                  }
                  else {
  
                      id innerKey = [ele description];
                      [data setObject:[[inner valueForKey:innerKey] description] forKey:[ele description]];
                  }
              }
          }
          else {
  
              [data setObject:[inner description] forKey:[element description]];
          }
      }
  
      self.weatherData = data;
      NSLog([self.weatherData description]) **//there is data**
  }
  
  @end
  </code></pre>
  
  <p>However every time I call this from by city object I get nothing back at all.</p>
  
  <pre><code>#import &lt;Foundation/Foundation.h&gt;
  #import "WeatherFetcher.h"
  
  @interface City : NSObject {
  
  }
  
  @property (nonatomic, strong) NSString *cityName;
  @property (nonatomic, strong) NSString *stateName;
  @property (nonatomic, strong) UIImage *cityPicture;
  @property (nonatomic, strong) NSString *weather;
  @property (nonatomic, strong) NSMutableDictionary *weatherData;
  
  -(NSString *)getWeather;
  
  @end
  </code></pre>
  
  <p>UI calls getWeather by a button press to get the string value to be displayed on screen</p>
  
  <pre><code>@implementation City {
  
  
  }
  
  -(NSString *)getWeather {
  
      //return self.weather;
  
      NSString *info = @"";
      WeatherFetcher *weatherFetcher = [[WeatherFetcher alloc] init];
      [weatherFetcher fetchWeather:self.cityName];
      self.weatherData = [weatherFetcher weatherData];
  
      for (id element in self.weatherData) {
  
          info = [info stringByAppendingString:[element description]];
          info = [info stringByAppendingString:@"--&gt;"];
          info = [info stringByAppendingString:[self.weatherData valueForKey:[element description]]];
          info = [info stringByAppendingString:@"\n"];
      }
  
      return info;
  }
  
  @end
  </code></pre>
  
  <p>What am I doing wrong here?</p>
  
  <p>getWeather method in the city class gets called when a button is pressed and I'm trying to display this string in a text area. I don't have much experience with Objective C and this is my first app other than Hello World app.</p>
  
  <p>Thank you!</p>