IOS fetching files from the real machine

Source: Internet
Author: User

The first step

Step two, add the code

1 //Write File2-(void) Writeoxy_rawdata: (NSString *) Datastr;3 {4NSDate * senddate=[NSDate Date];5NSDateFormatter *dateformatter=[[NSDateFormatter alloc] init];6[Dateformatter Setdateformat:@"YYYY-MM-DD Hh-mm-ss"];7NSString * locationstring=[Dateformatter stringfromdate:senddate];8NSLog (@"locationstring:%@", locationstring);9Nsarray *documentpaths =nssearchpathfordirectoriesindomains (NSDocumentDirectory, nsuserdomainmask,yes);Ten     //Use the C function nssearchpathfordirectoriesindomains to get the full path of the directory in the sandbox. The function has three parameters, a directory type, a he domain mask, and a Boolean value. Where the Boolean value indicates whether the path needs to be extended through the ~. And the first parameter is constant, which is nssearchpathdirectory. In iOS, the latter two parameters are the same: Nsuserdomainmask and YES.  OneNSString *ourdocumentpath =[documentpaths Objectatindex:0]; A     //Step two: Generate files under this path: -NSString *filename=[ourdocumentpath stringbyappendingpathcomponent:[nsstring stringWithFormat:@"%@.txt", locationstring]]; -     //FileName is the file name of the saved files the     //Step Three: Write data to the file: - [datastr writetofile:filename atomically:yes encoding:nsutf8stringencoding Error:nil]; -     //writes the NSData type Object data to the file, the file name is filename, and the last: reads the data from the file: -}
View Code

The third step, as in itunes

IOS fetching files from the real machine

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.