skip to Main Content

I am a React native developer and I was trying to integrate a native ios code.

One of the instance takes NSURL * which should be a local path I guess

https://github.com/uber/startup-reason-reporter/blob/master/StartupReasonReporter/StartupReasonReporterPriorRunInfo/UBApplicationStartupReasonReporterPriorRunInfo.h#L21

+ (nonnull instancetype)priorRunAtDirectoryURL:(nullable NSURL *)directoryURL;

I am not sure what does localPath Url looks like in IOS, like what should I pass? for example?

Ps: intentionally including swift tag as well because I think swift developers could also answer it.

2

Answers


  1. Based on description of that function:

    • Returns the prior run information stored to disk at the given directory URL.
    • @param directoryURL The directory to use to to store the startup reason data.
    • @return the previous startup reason data if it was present on disk, or empty startup reason object.
      */

    you need to provide a directory they can write into. So Apps’s document directory would be the best (as a root) + whatever folder you want (which, based on their code, they will even create for you).
    So:

    NSURL* docs = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
    NSURL* myCrashes = [docs URLByAppendingPathComponent:@"myCrashes" isDirectory:TRUE];
    

    it will look something like:

    file:///some/path/to/app/sandbox/data/Documents/myCrashes
    
    Login or Signup to reply.
  2. Try looking up documentation for

    - (NSArray<NSURL *> *)URLsForDirectory:(NSSearchPathDirectory)directory 
                             inDomains:(NSSearchPathDomainMask)domainMask;`
    

    That will get you the URL and check out FileManager.SearchPathDirectory enum for all the viable options:

    Here’s an example for getting the caches directory

    NSURL* url = [[[NSFileManager defaultManager] URLsForDirectory:NSCachesDirectory inDomains:NSUserDomainMask] lastObject];`
    

    It could be any one of the 25-26 options in SearchPathDirectory depending on where they put that stuff.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search