Usage of IOS sandbox

Source: Internet
Author: User

To create the path to the sandbox:

Nsfilemanager *filemanager = [Nsfilemanager Defaultmanager];
nsarray *documentpaths= nssearchpathfordirectoriesindomains (nsdocumentdirectory, NSUserDomainMask, YES);
NSLog (@ "Documentpath%@", documentpaths);
nsstring *ourdocumentpath=[documentpaths objectatindex:0];
NSLog (@ "ourdocumentpath=%@", Ourdocumentpath);
nsstring *filename=[ourdocumentpath stringbyappendingpathcomponent:@ "moveee"];
[FileManager createdirectoryatpath:filename withintermediatedirectories:yes attributes:nil Error:nil];


Add a folder, add a file

< Span style= "FONT-SIZE:14PX; line-height:25.2000007629395px ">

< Span style= "FONT-SIZE:14PX; line-height:25.2000007629395px ">    nsstring *testpath = [Testdirectory stringbyappendingpathcomponent:@" Test00.txt "]; &NBSP
    NSString *testpath2 = [testdirectory stringbyappendingpathcomponent:@ "Test22.txt"];  
    NSString *testpath3 = [testdirectory stringbyappendingpathcomponent:@ "Test33.txt"];  
    NSString *string = @ "Write content, write string";
    [FileManager createfileatpath:testpath contents:[string  datausingencoding: Nsutf8stringencoding] Attributes:nil];
    [FileManager createfileatpath:testpath2 contents:[string  datausingencoding: Nsutf8stringencoding] Attributes:nil];
    [FileManager createfileatpath:testpath3 contents:[string  datausingencoding: Nsutf8stringencoding] Attributes:nil];

< Span style= "FONT-SIZE:14PX; line-height:25.2000007629395px "> Get all filenames in directory column

Nsarray *paths = Nssearchpathfordirectoriesindomains (NSDocumentDirectory, Nsuserdomainmask, YES);
NSString *documentsdirectory = [Paths objectatindex:0];
NSLog (@ "documentsdirectory%@", documentsdirectory);
Nsfilemanager *filemanage = [Nsfilemanager Defaultmanager];
NSString *mydirectory = [documentsdirectory stringbyappendingpathcomponent:@ "test"];
Nsarray *file = [Filemanage subpathsofdirectoryatpath:mydirectory error:nil];
NSLog (@ "%@", file);
Nsarray *files = [Filemanage subpathsatpath:mydirectory];
NSLog (@ "%@", files);

Usage of IOS sandbox

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.