iphone - nsdictionary objectforkey - search and get that value -


I am using NSDictionary in my iPhone app to get the value of a key "objectForKey:" method I am using a thread (the first thread) adding a key-value to a dictionary and another thread (the second thread), reading them. In the second thread, I want to get a value for that key which can not be added to the thread several times before that time. So, in the 2nd thread, I want to find some keys and then get that value. Possible? If I provide a key in that dictionary that does not exist? What will it be back to?

You need to use your synchronized access to the dictionary for your operation to be threadsif According to the document, for your question about the method, it will return zero if the key is not present (i.e. there is no related value) in the dictionary.


Comments