Dictionary object (nsdictionary and nsmutabledictionary)-objective-C

Source: Internet
Author: User

Nsdictionary serves the same purpose as the dictionary class in Java and provides a set of "key-value" pairs.

Summary of common nsdictionary Methods
+ (ID) dictionarywithobjectsandkeys: obj1, key1, obj2, key2, ...... Nil Add objects and key values in sequence to create a dictionary. Note that the end is nil.
-(ID) initwithobjectsandkeys: obj1, key1, obj2, key2, ...... Nil Initialize a new dictionary, adding objects and values in sequence, ending with nil
-(Unsigned INT) count Returns the number of records in the dictionary.
-(Nsenumerator *) keynsenumerator Returns all keys in the dictionary to an nsenumerator object.
-(Nsarray *) keyssortedbyvalueusingselector :( SEL) Selector Sort all keys in the dictionary by the method specified by selector and return the result.
-(Nsenumerator *) objectenumerator Returns all values in the dictionary to an nsenumetator type object.
-(ID) objectforkey: Key Returns the object with the specified key value.

Summary of common nsmutabledictionary Methods
+ (ID) dictionarywithcapacity: Size Create a variable Dictionary of size
-(ID) initwithcapacity: Size Initializes a variable Dictionary of size.
-(Void) removeallobjects Delete all elements in the dictionary
-(Void) removeobjectforkey: Key Delete the key position element in the dictionary
-(Void) setobject: OBJ forkey: Key Add (Key, OBJ) to the dictionary. If the key already exists, replace it with obj.

Related Article

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.