Thursday, May 9, 2013

NSDictionary descriptionWithLocale example ios


Returns a string object that represents the contents of the dictionary, formatted as a property list.
- (NSString *)descriptionWithLocale:(id)locale
Parameters of [NSDictionary descriptionWithLocale]
An object that specifies options used for formatting each of the dictionary’s keys and values; pass nil if you don’t want them formatted.
On iOS and OS X v10.5 and later, either an instance of NSDictionary or an NSLocale object may be used forlocale. On OS X v10.4 and earlier it must be an instance of NSDictionary.
Discussion of [NSDictionary descriptionWithLocale]
For a description of how locale is applied to each element in the dictionary, see descriptionWithLocale:indent:.
If each key in the dictionary responds to compare:, the entries are listed in ascending order by key, otherwise the order in which the entries are listed is undefined.
Example of [NSDictionary descriptionWithLocale]
NSArray *keys = [NSArray arrayWithObjects:@"key1", @"key2", nil];
NSArray *objects = [NSArray arrayWithObjects:@"value1", @"value2", nil];
NSDictionary *dictionary = [NSDictionary dictionaryWithObjects :objects 
NSLog(@"content=%@", [dictionary descriptionWithLocale:[NSLocale currentLocale]]);
Example of [NSDictionary descriptionWithLocale]
NSDictionary *activeMissions = [NSDictionary dictionaryWithObjects: [NSArray arrayWithObjects:tiger, bull, peacock, nil]
                                                  forKeys: [NSArray arrayWithObjects:@tiger, @"bull", @"peacock", nil]];

NSLog(@"content=%@", [activeMissions descriptionWithLocale:[NSLocale currentLocale]]);