打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
OC学习之XML属性列表归档

#import <Foundation/Foundation.h>


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

{


    @autoreleasepool {

        

       //写配置文件

       NSDictionary *glossary =

        [NSDictionarydictionaryWithObjectsAndKeys:

         @"A class defined",

        @"Class",

         @"A Function defined",

         @"Function",

         @"A Variable defined",

        @"Variable",nil];

        

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

        {

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

            

        }

       //读配置文件

       NSDictionary *glossaryRead ;

        glossaryRead = [NSDictionarydictionaryWithContentsOfFile:@"glossary" ];

       for (NSString *keyin glossaryRead ) {

           NSLog(@" %@:%@",key, [glossaryReadobjectForKey: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">

<plist version="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




本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Add Custom Blocks  |  Blockly  |  Google Developers
通过压缩SOAP改善XML Web service性能
精华推荐:内核模块编程的详细介绍_HackingYou_SupeSite/X-Space官...
main()与_tmain()的区别
Administration Tool Sections
可以直接调用的纯虚函数
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服