Junior — Middle
Selgitage, mis on andmestruktuur nimega 'sõnastik' ja kuidas seda kasutatakse.
sobes.tech AI
Vastus AI-lt
A dictionary is a data structure that stores key-value pairs. Each key is unique and associated with a specific value. In iOS, dictionaries are implemented using the classes NSDictionary (immutable) and NSMutableDictionary (mutable).
Dictionaries allow for quick lookup of values by key, which is useful for storing settings, parameters, or any data where the association between elements is important.
Example of using a dictionary in Objective-C:
NSDictionary *person = @{@"name": @"Ivan", @"age": @30};
NSString *name = person[@"name"]; // "Ivan"
NSNumber *age = person[@"age"]; // 30
Dictionaries are widely used for structuring data, passing parameters, and storing configurations.