Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

nativelly how to know the writeable/shared folder of the app?

Discussion in 'iOS and tvOS' started by tyoc213, Dec 18, 2014.

  1. tyoc213

    tyoc213

    Joined:
    Nov 14, 2011
    Posts:
    168
    I need to write a plugin that save to the readable/writeable persistent path of the game.

    Is there a way to know?? or should I pass the value somewhere at runtime?
     
  2. Veemix

    Veemix

    Joined:
    Dec 5, 2014
    Posts:
    25
    If you want to do this in C#, just construct a path to the app's Documents directory using:
    Code (csharp):
    1.  
    2. Application.persistentDataPath + "/" + fileName;
    3.  
    If you want to do this using Objective-C native code, you will need to access it like this:
    Code (csharp):
    1.  
    2. NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    3. NSString *documentsDir = [paths objectAtIndex:0];
    4. NSString *myDocumentsFolderFilePath = [documentsDir stringByAppendingPathComponent:@"myFileName.txt"];
    5.  
     
    Last edited: Dec 18, 2014