I have been struggling all day with one of that simple mistakes that makes you loose a lot of time while trying to figure out where the error actually is. It was about a NSDictionary. I used this dictionary to set the headers for a communication, and every time I found that the headers where not there. What was happening?

The initialization code of the NSDictionary was something similar to this:

NSDictionary * headers = [NSDictionary dictionaryWithObjectsAndKeys:
    object1, key1,
    object2, key2,
    object3, key3,

The problem was that dictionaryWithObjectsAndKeys actually stops adding items to the dictionary as soon as it finds a nil entry, and due to a unchecked condition, object1 was nil in certain situations, thus giving me an empty NSDictionary. The lesson learned is: if you use dictionaryWithObjectsAndKeys: to initialize a NSDictionary, you must put your checks in place to make sure that all of the items you are initializing the dictionary with are valid, non-nil objects.

Hope this helps!