Domanda

I have a networking method that provides a friendly interface to my API. Something like:

    getWeatherForCities:(NSArray *)cityCodes 
              startDate:(NSDate *)startDate
                endDate:(NSDate *)endDate 
             useCelcius:(BOOL)useCelcius
             maxResults:(NSNumber *)maxResults

This is called multiple times in my app, sometimes concurrently with different parameters. There is also a completion and failure block but they aren't needed here.

I would like to add an option that tells the method only to execute the completion block if the data is different to the last time it was requested with the same parameters. This way some consumers can say that they want to know everything, and others can ask only for data if it is new.

It seems like I need some way to store a representation of all the parameters, alongside the last received response for those parameters. I would love to do this in an NSDictionary, but am open to other ideas. Is there some way to convert the parameters into a unique key? Or some better solution?

È stato utile?

Soluzione

I am currently using the [dictionary description] as the key.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top