title: How to use NSMutableDictionary in an UIAlertView?
body: <p>I am making a calorie counter and I have created an UIAlertView which gives me list of food items. I have made a <code>NSMutableDictionary</code> containing the food and the calories:</p>
  
  <pre><code>@implementation FoodDatabase
  
  -(id)init 
  {    
    self = [super init];
    if(self) 
    {
      food= [[NSMutableDictionary alloc] init];
      [food setObject:@"111" forKey:@"Rice"];       
    }
    return self;
  }
  
  
  -(NSString *) foodList: (NSString *) foodItem 
  {
      for(NSString *key in [food allKeys]) 
      {        
          if([foodItem isEqual: key]) 
          {
              NSLog(@"%@",foodItem);
              return [food objectForKey:foodItem];
          }
      }
   }
  
  
  @end
  </code></pre>
  
  <p>In another class, I have created an <code>UIAlertView</code> which gives a list of food items. This is the code snippet for the item Rice:</p>
  
  <pre><code>NSString *buttonTitle = [alertView buttonTitleAtIndex:buttonIndex];
  if([buttonTitle isEqualToString:@"Rice"])
  {        
      NSString *xyz = [foodData foodList: @"Rice"];
      food_calorie = ([xyz floatValue]);
  
      UIAlertView *rice_alert=[[UIAlertView alloc] initWithTitle:@"Enter quantity of rice consumed" message:@"100 gms = 111 calories" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil];
  
      [rice_alert addTextFieldWithValue:@"" label:@"Enter quantity in gms"];
  
      RiceText = [rice_alert textFieldAtIndex:0];
      RiceText.keyboardType = UIKeyboardTypeNumberPad;
      RiceText.clearsOnBeginEditing = YES;
      RiceText.clearButtonMode = UITextFieldViewModeWhileEditing;
      RiceText.keyboardAppearance = UIKeyboardAppearanceAlert;
      rice_alert.tag = RiceAlertView;
  
      [rice_alert show];
      [rice_alert release];
  
  }
  </code></pre>
  
  <p>I calculate the total calories by using the value entered by the user in the <code>_RiceText_</code> and the value of the <code>_object_</code> returned for a specific key (in this case rice). But it seems not to be returning the value of the <code>_object_</code> as the <code>NSLog</code> shows <code>_(null)_</code> for the value of <code>_xyz_</code>. Where am I going wrong?? </p>