Read:
---------------------------------------------------------------
// First, read the data in studentinfo. plist. Nsstring * plistpath = [[nsbundle mainbundle] pathforresource: @" Custominfo " Oftype: @" Plist " ]; Nsdictionary * Dictionary = [[Nsdictionary alloc] initwithcontentsoffile: plistpath]; // Enter student information in the view Nsdictionary * tmpinfo = [dictionary objectforkey: @" Student " ]; Self. stuname. Text = [Nsstring stringwithformat: @" % @ " , [Tmpinfo objectforkey: @" Name " ]; Self. stusex. Text = [Nsstring stringwithformat: @" % @ " , [Tmpinfo objectforkey: @" Sex " ]; Self. stunum. Text = [Nsstring stringwithformat: @" % @ " , [Tmpinfo objectforkey: @" Num " ]; // Write instructor information to the view Tmpinfo = [dictionary objectforkey: @" Mentor " ]; Self. mtname. Text = [Nsstring stringwithformat: @" % @ " , [Tmpinfo objectforkey: @" Name " ]; Self. mtsex. Text = [Nsstring stringwithformat: @" % @ " , [Tmpinfo objectforkey: @" Sex " ];
New write:
---------------------------------------------------------------
Nsmutabledictionary * dictplist = [[Nsmutabledictionary alloc] init]; // Define the attributes of the first plug-in Nsmutabledictionary * plugin1 = [[Nsmutabledictionary alloc] init]; [plugin1 setobject: @" Zhang San " Forkey: @" Name1 " ]; [Plugin1 setobject: @" Li Si " Forkey: @" Name2 " ]; // Define the attributes of the second plug-in Nsmutabledictionary * plugin2 = [[Nsmutabledictionary alloc] init]; [plugin2 setobject: @" Wang Wu " Forkey: @" Name1 " ]; [Plugin2 setobject: @" Zhao Bin " Forkey: @" Name2 " ]; // Set attribute values [Dictplist setobject: plugin1 forkey: @" First Class " ]; [Dictplist setobject: plugin2 forkey: @" Class 2 " ]; // Write files [Dictplist writetofile: plistpath atomically: Yes];
// Modify a configuration item.
// Load the configuration file. Nsstring * plistpath = [nsstring stringwithformat: @" % @/Letters. plist " , [[Globals getresourcemanager] getrespath]; nsmutabledictionary * Dicwrite = [[Nsmutabledictionary alloc] initwithcontentsoffile: plistpath] mutablecopy]; nsmutabledictionary * Dicwletter = [Dicwrite objectforkey: letter]; nsstring * V = alertview. Tag = 1 ? @" 1 " : @" 0 " ; [Dicwletter setvalue: V forkey: @" Isok " ]; [Dicwrite setvalue: dicwletter forkey: letter]; [dicwrite writetofile: plistpath atomically: Yes]; [dicwrite release]; dicwrite = Nil;