OC学习之XML属性列表归档

前端之家收集整理的这篇文章主要介绍了OC学习之XML属性列表归档前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

#import <Foundation/Foundation.h>


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

{


@autoreleasepool {

//配置文件

NSDictionary *glossary =

[NSDictionary dictionaryWithObjectsAndKeys:

@"A class defined",

@"Class",

@"A Function defined",

@"Function",27)"> @"A Variable defined",

@"Variable",nil];

if([glossary writeToFile:@"glossary" atomically:YES] == NO )

{

NSLog(@"Save to file Failed!");

}

//配置文件

NSDictionary *glossaryRead ;

glossaryRead = [NSDictionary dictionaryWithContentsOfFile:@"glossary" ];

for (NSString *key in glossaryRead ) {

NSLog(@" %@:%@",key,[glossaryRead objectForKey:key]);

}

}

return 0;

}

XML 文件

<?xml version="1.0"encoding="UTF-8"?>

<!DOCTYPE plist PUBLIC"-//Apple//DTD PLIST 1.0//EN""http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plistversion="1.0">

<dict>

<key>Class</key>

<string>A class Defined</string>

<key>Function</key>

<string>A Function Defined</string>

<key>Variable</key>

<string>A Variable defined</string>

</dict>

</plist>

结果:

2013-09-12 10:28:17.359 Test_File[527:303] Variable:A Variable defined

2013-09-12 10:28:17.360 Test_File[527:303] Function:A Function defined

2013-09-12 10:28:17.361 Test_File[527:303] Class:A class defined

原文链接:https://www.f2er.com/xml/299856.html

猜你在找的XML相关文章