ios5 - Copy data file from Xcode to iPad sandbox -


i created app in xcode , added text file app open , display.

how can text file ipad sandbox documents directory testing?

there few things need do:

  1. create path documents directory
  2. make sure text file in app bundle (drag/drop xcode should fine)
  3. copy text file name app bundle documents directory

try this:

// documents path nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring *documentspath = [paths objectatindex:0];  // destination path nsstring *fileindocumentspath = [documentspath stringbyappendingpathcomponent:@"name-of-your-file.txt"];  // origin path nsstring *fileinbundlepath = [[nsbundle mainbundle] pathforresource:@"name-of-your-file" oftype:@"txt"];  // file manager copying nserror *error = nil; nsfilemanager *filemanager = [nsfilemanager defaultmanager]; [filemanager copyitematpath:fileinbundlepath topath:fileindocumentspath error:&error]; 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -