#import <Foundation/Foundation.h>
int main (int argc, const char * argv[]) {
@autoreleasepool {
/* Dictionary: Nsdictionary
The difference between the array used to store the data: The dictionary uses key-value methods, unordered
2 is the equivalent of using a dictionary to find specific words in a directory
3 in the form of Key-value data, value is used to store data, key to retrieve data
4 dictionary in Cocoa: variable/non-variable
Attention:
1.key is usually a string object and can be any type
2. The same key is not allowed in the dictionary, allowing the same value
*/
Immutable dictionaries
Assigned value 1
NSNumber *num=[nsnumber numberwithint:100];
Nsdictionary *dic=[nsdictionary dictionarywithobject:num forkey:@ "Monry"];
NSLog (@ "%@", DIC);
Assignment 2 Jay is k name is value
Nsdictionary *dics=[nsdictionary dictionarywithobjectsandkeys:@ "Jay", @ "name", @ "@", @ "age", @ "F", @ "gender", nil];
NSLog (@ "%@", dics);
Assigned value 3
Nsdictionary *[email protected]{@ "name": @ "Jay",
@ "Age": @ "23",
@ "Gender": @ "M"
};
Nsdictionary *dicd=[nsdictionary DICTIONARYWITHDICTIONARY:DICF];
NSLog (@ "%@", DICD);
Key-value, how many are there?
Nsinteger Count=[dicd Count];
NSLog (@ "%ld", count);
Gets the value in the dictionary
NSString *name=[dicd objectforkey:@ "name"];
NSLog (@ "%@", name);
Get all the values in the dictionary
Nsarray *arr=[dicd allvalues];
NSLog (@ "%@", arr);
Get all the keys in the dictionary
Nsarray *arra=[dicd AllKeys];
for (id str in ARRA) {
NSLog (@ "%@", str);
};
}
return 0
}
Immutable dictionary assignment How many in the dictionary get all the values for all value values in the dictionary