#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.