Ios:plist instances

Source: Internet
Author: User

1 //2 //main.m3 //osxdemo0601_plist4 //5 //Created by Yao_yu on 14-6-3.6 //Copyright (c) 2014 Yao_yu. All rights reserved.7 //8 9 #import<Foundation/Foundation.h>Ten  OneBOOL Isfile (NSString *path) A { -Nsfilemanager *filemanager =[Nsfilemanager Defaultmanager]; -BOOL Isdir =NO; the     if([FileManager fileexistsatpath:path isdirectory: &Isdir]) { -         returnIsdir = =NO; -     } -     returnNO; + } -  +BOOL Isdir (NSString *path) A { atNsfilemanager *filemanager =[Nsfilemanager Defaultmanager]; -BOOL Isdir =NO; -     if([FileManager fileexistsatpath:path isdirectory: &Isdir]) { -         returnIsdir = =YES; -     } -     returnNO; in } -  to intMainintargcConst Char*argv[]) + { -  the @autoreleasepool { *         //get the document directory $Nsarray *paths =nssearchpathfordirectoriesindomains (NSDocumentDirectory, Nsuserdomainmask, YES);Panax NotoginsengNSString *documentdir = [Paths Objectatindex:0]; -          the         //get (Create) a custom data Catalog +NSString *testdir = [[Documentdir stringbyappendingpathcomponent:@"YY"] stringByAppendingPathComponent:@"Data"]; ANsfilemanager *fileman =[Nsfilemanager Defaultmanager]; the         if(!Isdir (testDir)) + [Fileman createdirectoryatpath:testdir withintermediatedirectories:yes attributes:nil Error:nil]; -          $         //Create a plist file, serialize the dictionary $NSString * Plistfile = [TestDir stringbyappendingpathcomponent:@"my.plist"]; -         if(!isfile (plistfile)) -         { theNsmutabledictionary *a = [[Nsmutabledictionary alloc] initwithobjectsandkeys:@1,@"A", @2,@"B", nil]; - [a writetofile:plistfile atomically:yes];Wuyi         } the          -         //read plist file, deserialize WuNsmutabledictionary *plist =[Nsmutabledictionary dictionarywithcontentsoffile:plistfile]; -[Plist setobject:@"China"Forkey:@"National"]; AboutNSLog (@"%@", plist); $     } -     return 0; -}

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.