Reputation: 2412
I'm using this to get object from Key
NSUserDefaults *defaults=[NSUserDefaults standardUserDefaults];
NSString *object=[defaults objectForKey:someKey];
How I can get opposite effect? Key from Object? Something like
NSString *key=[defaults keyForObject:object];
Thanks
Upvotes: 0
Views: 987
Reputation: 16827
You can get the NSUserDefaults
dictionary (with the dictionaryRepresentation
method). You can then use the dictionary method
- (NSSet *)keysOfEntriesPassingTest:(BOOL (^)(id key, id obj, BOOL *stop))predicate
or
- (NSArray *)allKeysForObject:(id)anObject
to get the key for your object.
Upvotes: 5