title: iOS: Why can't I set nil to NSDictionary value?
body: <p>This might be very basic question but I was wondering why can't I assign nil as NSDictionary value? I have following statement many places in my code. If <code>[q objectForKey:@"text"]</code> is nil then App is crashing. </p>
  
  <pre><code>NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithCapacity:2];
  [dict setObject:[q objectForKey:@"text"] forKey:@"text"];
  </code></pre>
  
  <p>I have to check everywhere for the nil before assigning it to dictionary. Is this the only correct way of doing? Am I missing something obvious? </p>
  
  <pre><code>if([q objectForKey:@"text"] != nil)
      [dict setObject:[q objectForKey:@"text"] forKey:@"text"];
  else
      [dict setObject:@"" forKey:@"text"];
  </code></pre>