Immutable dictionary assignment How many in the dictionary get all the values for all value values in the dictionary

Source: Internet
Author: User

#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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.