objective-ccocoa-touchnsubiquitouskeyvaluestore

NSUbiquitousKeyValueStore class and -boolForKey: method


Here's the link

boolForKey: Returns the Boolean value associated with the specified key.

-(BOOL)boolForKey:(NSString *)aKey Parameters aKey A key in the key-value store.

Return Value If a Boolean value is associated with the specified key, that value is returned. If the key was not found, this method returns NO.

So, having spent my last 4 hours, i still can't figure out a way to distinguish these 2 cases in code:

A) The return value is NO after setting a boolean value with NO with a specified key

from:

B) the return value is NO because no such specified key was found!

any help would be appreciated :)


Solution

  • You can use objectForKey: to see if an object actually exists for that key.