Objective-c dictionary use of detailed __objective-c

Source: Internet
Author: User
Tags uikit
#import <UIKit/UIKit.h>
#import "AppDelegate.h"

int main (int argc, char * argv[]) {

  

  //similar to the map in Java, That is, the key value pair;
  nsdictionary *dict = @{@ "name": @ "Zhangsan", @ "age": @23};

  Print out the whole dictionary;
  NSLog (@ "%@", dict);
  
  Remove a value from the dictionary;
  NSLog (@ "%@", [dict objectforkey:@ "name"]);
  
  Read a plist dictionary;
  the//plist file can be used as a configuration file to store an array or a dictionary. A similar XML configuration file in Android. Need to be used well.
  nsdictionary *plistdict = [nsdictionary dictionarywithcontentsoffile:[[nsbundle mainbundle] pathForResource:@ " Data "oftype:@" plist "]];
  NSLog (@ "Dictionary in plist file:%@", plistdict);
  NSLog (@ "Age in Plist:%@", [Plistdict objectforkey:@ "ages"]);
  
  
}


The output results are as follows:

2015-09-22 10:50:32.067 mutablearraydemo[90943:3898163] {
Age = 23;
name = Zhangsan;
}
2015-09-22 10:50:32.069 mutablearraydemo[90943:3898163] Zhangsan
2015-09-22 10:50:32.082 mutablearraydemo[90943:3898163] plist A dictionary in a file: {
Age = 25;
name = Jack;
}
2015-09-22 10:50:32.082 mutablearraydemo[90943:3898163] plist Age: 25



GitHub home: https://github.com/chenyufeng1991. You are welcome to visit.

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.