Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can copy all files from your resource folders, but I doubt you really want to do that, do you? After all these are also app resources (like a strings file or graphics only for UI buttons, etc.)</p> <p>So you may want to have a sub-directory in your resources folder (e.g. named <code>FilesToCopy</code>) with all the files you want to copy (e.g. <code>Photo.png</code> is found at <code>Contents/Resources/FilesToCopy/Photo.png</code>)</p> <p>To get the content of a directory, just use</p> <pre><code>NSError * err; NSArray * files; NSString * srcPath; NSString * dstPath; NSFileManager * man; srcPath = [self getSrcPath]; dstPath = [self getDstPath]; man = [[NSFileManager alloc] init]; files = [man contentsOfDirectoryAtPath:srcPath error:&amp;err]; </code></pre> <p>Then you can copy one file at a time:</p> <pre><code>for (NSString *aFile in files) { BOOL success; NSString * srcFile = [srcPath stringByAppendingPathComponent:aFile]; NSString * dstFile = [dstPath stringByAppendingPathComponent:aFile]; success = [man copyItemAtPath:srcFile toPath:dstFile error:&amp;err]; // Verify success } </code></pre> <p>Now you only need <code>srcPath</code> and <code>dstPath</code>.</p> <pre><code>- (NSString *)getSrcPath { return [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"FilesToCopy"]; } - (NSString *)getDstPath { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES); return [paths objectAtIndex:0]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload